Dashut
Posts: 142
Joined: Tue May 04, 2010 4:41 pm

.Net Custom Action not working when trying to add property

I have managed to add a DLL and call the Custom Action. On my DLL I created a MessageBox, and so I know that it really reaches that place (MessageBox pops up).
So far: it works.
I also tried adding some new "Custom Action Parameter" from "Edit .Net Custom Action", and then "new" and then under "New Installer Class Parameter" I added:
Name: Hello
Value: World

The "Action Data" created was:

Code: Select all

 /LogFile= /ReqVersion=2.0.50727 /InstallType=notransaction /Action=Install /Hello=World "[#TestDLL.dll]" "[TempFolder]dotNetCustAct.dll_Config.xml"
and this works too! (popup MessageBox of the DLL function was called and program was installed).

Now here's what doesn't work:
Again I went to "Edit .Net Custom Action", pressed the "new" button, and in dialog "New Installer Class Parameter" I added the following:
Name: MyTest
Value: [APPDIR]
The "Action Data" created was:

Code: Select all

/LogFile= /ReqVersion=2.0.50727 /InstallType=notransaction /Action=Install /MyTest="[APPDIR]" "[#TestDLL.dll]" "[TempFolder]dotNetCustAct.dll_Config.xml"
but this didn't work, and during installation I received the following error:
"The dialog ErrorDlg has the error style bit set, but is not an error dialog".

And then the installation fails with "The TestDLL Setup Wizard ended prematurely" and then you have to press the "Finish" button.

What am I doing wrong here?

All my TestDLL currently does is:

Code: Select all

namespace TestDLL
{
    [System.ComponentModel.RunInstaller(true)]
    public class Class1 : System.Configuration.Install.Installer
    {
        public override void Install(System.Collections.IDictionary stateSaver)
        {
            base.Install(stateSaver);
            System.Windows.Forms.MessageBox.Show("Hello world!");
        }
    }
}
I'll also add, that when I run with "Run and Log" I see the following in the log (log is when the popup window for failure is shown):

Code: Select all

Action start 9:29:58: AI_DATA_SETTER.
MSI (s) (34:20) [09:29:58:890]: PROPERTY CHANGE: Adding CustomActionData property. Its value is '/LogFile= /ReqVersion=2.0.50727 /InstallType=notransaction /Action=Install /MyTest="C:\Program Files\Volicon\_TestingCustomAction\" "C:\Program Files\Volicon\_TestingCustomAction\TestDLL.dll" "C:\DOCUME~1\Dashut\LOCALS~1\Temp\dotNetCustAct.dll_Config.xml"'.
Action ended 9:29:58: AI_DATA_SETTER. Return value 1.
MSI (s) (34:20) [09:29:58:937]: Doing action: dotNetCustAct.dll
Action 9:29:58: dotNetCustAct.dll. 
Action start 9:29:58: dotNetCustAct.dll.
MSI (s) (34:48) [09:29:59:000]: Invoking remote custom action. DLL: C:\windows\Installer\MSI1D9D.tmp, Entrypoint: LaunchDotNetCustomAction
MSI (c) (94:5C) [09:29:59:046]: Font created.  Charset: Req=0, Ret=0, Font: Req=, Ret=Arial

Code: Select all

and after I close the error dialog:
Error 2869. The dialog ErrorDlg has the error style bit set, but is not an error dialog.
MSI (c) (94:5C) [09:31:14:343]: Product: _TestingCustomAction -- Error 2869. The dialog ErrorDlg has the error style bit set, but is not an error dialog.

Error 1001. 
...
Dashut.
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: .Net Custom Action not working when trying to add property

Hello,

The issue lies where it sais /MyTest="[APPDIR]".
Folder properties like APPDIR end in a backslash. The resulting backslash escapes the following quote when evaluated. Simply place a white space between '[APPDIR]' and the following quote so that the result is /MyTest="[APPDIR] ".
We will improve this in the future.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
Dashut
Posts: 142
Joined: Tue May 04, 2010 4:41 pm

Re: .Net Custom Action not working when trying to add property

Gabriel:
Thanks for you reply.
I just tried what you suggested, but received the same error/result.
Here's the "run and log" until the error dialog popup:

Code: Select all

MSI (s) (4C:80) [14:12:03:968]: Doing action: AI_DATA_SETTER
Action 14:12:03: AI_DATA_SETTER. 
Action start 14:12:04: AI_DATA_SETTER.
MSI (s) (4C:80) [14:12:04:015]: PROPERTY CHANGE: Adding CustomActionData property. Its value is '/LogFile= /ReqVersion=2.0.50727 /InstallType=notransaction /Action=Install /MyTest="C:\Program Files\Volicon\_TestingCustomAction\ " "C:\Program Files\Volicon\_TestingCustomAction\TestDLL.dll" "C:\DOCUME~1\Dashut\LOCALS~1\Temp\dotNetCustAct.dll_Config.xml"'.
Action ended 14:12:04: AI_DATA_SETTER. Return value 1.
MSI (s) (4C:80) [14:12:04:062]: Doing action: dotNetCustAct.dll
Action 14:12:04: dotNetCustAct.dll. 
Action start 14:12:04: dotNetCustAct.dll.
MSI (s) (4C:30) [14:12:04:109]: Invoking remote custom action. DLL: C:\windows\Installer\MSI1F3A.tmp, Entrypoint: LaunchDotNetCustomAction
MSI (c) (DC:40) [14:12:04:171]: Font created.  Charset: Req=0, Ret=0, Font: Req=, Ret=Arial
so as you can see, there's a space, but it doesn' t have a positive effect : /MyTest="C:\Program Files\Volicon\_TestingCustomAction\ "

Anything else I can do?
Dashut.
Dashut
Posts: 142
Joined: Tue May 04, 2010 4:41 pm

Re: .Net Custom Action not working when trying to add property

Very weird! I tried adding the word "test" after the [APPDIR]
so the new property is:

Code: Select all

"[APPDIR]test"
and this worked!
So I replaced the word "test" with 4 spaces: and this also worked!
Then I started removing spaces until I was left with ONE - just like you offered! - and that also worked!

So that's weird...
Initially it didn't work when adding just one space, but then after 4 spaces and then removing them one by one (build/run msi) - it worked!
For sure there's some bug in the program.

I hope you'll fix this in your next/following release.

Many thanks, Dashut.
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: .Net Custom Action not working when trying to add property

Hello,

Please make sure your custom action is set as deferred with no impersonation.
Let me know how it went.

Regards,
gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
Dashut
Posts: 142
Joined: Tue May 04, 2010 4:41 pm

Re: .Net Custom Action not working when trying to add property

If my custom action is set to "Deferred" or "Deferred with no impersonation", then the custom action isn't called at all...
Dashut.
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: .Net Custom Action not working when trying to add property

Hello,

Please send your .aip project file to support at advancedinstaller dot com so we can further investigate.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
Dashut
Posts: 142
Joined: Tue May 04, 2010 4:41 pm

Re: .Net Custom Action not working when trying to add property

I just sent to support my TestDLL.dll (C# dll project) and the *.aip files where I tried to create the Custom Action.
Although I want the custom action to work in "uninstall", but it's NOT working also for "install" (Advanced Installer 7.6.1): all my examples are for a custom action in the "install".

It didn't work when for "Immediate Execution", didn't work for "Deferred", and didn't work for "Deferred with no impersonation".

What you can do is: just create a simple Enterprise Project, that has only ONE DLL (you can go ahead and use my TestDLL.dll and call it's custom action), and call it's Custom Action (in C#).
Since my TestDLL.dll (c#) calls a MessageBox with "Hello World!", you can know if it worked. You can create your own (DLL that responds to the Custom Action call), or use mine.
Once we get the Custom Action working, we can most probably also solve the problem with the Patch.
Note that I didn't manage to call the Custom Action also without adding more parameters other then the default ones (meaning: just creating a default Custom Action call doesn't work).

Here is the list of files I sent you:
CustomActionAsDeferredWithNoImpersonationNotCalled.aip
CustomActionAsImmediateExecutionCausesError.aip
CustomActionAsDeferredNotCalled.aip
TestDLL.dll

Many thanks, Dashut.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: .Net Custom Action not working when trying to add property

Hi,
Since my TestDLL.dll (c#) calls a MessageBox with "Hello World!", you can know if it worked.
The message box was shown only after we changed the Action parameter to "Install". In the projects you sent it was set to "Uninstall". Perhaps this is the problem.

I answered to your post in the other thread:
http://www.advancedinstaller.com/forums ... 134#p30134

Please try using only one thread for a problem.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Dashut
Posts: 142
Joined: Tue May 04, 2010 4:41 pm

Re: .Net Custom Action not working when trying to add property

I created two threads, since one problem I had was the Custom Action which was not working for me, and the other was to create a patch.
Sorry for the confusion.

I'll continue to investigate based on your recommendations.

Please note: that I haven't always managed to call the Custom Action even when choosing "install" (and not "uninstall" which is actually what we need to test).
It seems like Advanced Installer is not completely stable when it comes to Custom Actions. I have managed to make it work for "install" before (after "playing" with it a lot!), but now I haven't. Maybe this is since I moved from 7.6 to version 7.6.1 of Advanced Installer.

I'll continue to look at what you suggest and supply feedback to you.
Dashut.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: .Net Custom Action not working when trying to add property

Hi Dashut,

On our test machines the action was always executed, even if it didn't show any message boxes. If the problem persists, try generating a verbose log to determine if the action is executed. If it is, perhaps the problem is in the action code.

Please note that nothing was changed for .NET installer class actions in Advanced Installer 7.6.1. It should show the same behavior as in 7.6.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Dashut
Posts: 142
Joined: Tue May 04, 2010 4:41 pm

Re: .Net Custom Action not working when trying to add property

I see. So maybe it's like you say: it's executed, but not shown. Meaning: the MessageBox is not shown.

If you say it executes always, but just the MessageBox is not showing: then this might explain why I thought it's not working and it's giving an error: because one version of the TestDLL.dll shows MessageBox with "Hello world!" and ends, and another version of the TestDLL.dll shows a MessageBox with "Will throw exception" and then throws an exception which causes the Custom Action to fail. So if the one with the exception was used, and no MessageBox was shown: then this might have caused me to believe it's not working.

I have a couple of questions:
1. Why is the MessageBox not always shown?
2. How can I make sure the MessageBox is always shown?
3. What to choose for the MessageBox to appear both in "install" and "uninstall"? (meaning: "deferred" or "execute immediately" and so on).
4. Do it always work for you also for "uninstall" (the custom action)?

Dashut.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: .Net Custom Action not working when trying to add property

Hi,
1. Why is the MessageBox not always shown?
This depends on the custom action configuration. For example, if the message box is shown only for the "Install" action, calling "Uninstall" action will not show the message box.
2. How can I make sure the MessageBox is always shown?
Make sure the action you are calling uses code which shows a message box.
3. What to choose for the MessageBox to appear both in "install" and "uninstall"?
The .NET installer class action simply calls some methods from your DLL. What those methods do is controlled by you. If you want both install and uninstall to show message boxes, make sure that the code does this for both actions.
4. Do it always work for you also for "uninstall" (the custom action)?
Are you referring to your DLL? If so, we didn't test it for uninstall. We used the configuration you provided so we can try to determine the problem.

If you have problems understanding how .NET Installer Class Actions are used, perhaps this tutorial will help you.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Dashut
Posts: 142
Joined: Tue May 04, 2010 4:41 pm

Re: .Net Custom Action not working when trying to add property

Success!
What I did:
1. I uninstalled Advanced Installer completely. I had version 7.5.2 then 7.6 then I returned to 7.5.2 then 7.6, then updgraded to 7.6.1: so I completely removed it.
2. I installed Advanced Installer 7.6.1
3. I found some "dangling" "msiexec.exe". So I killed them all with TaskManager (found them in the Process section).
4. I created a simple Enterprise project with my TestDLL which causes a problem (custom action call) when uninstalling: 1.0.0. I installed it and checked that I can't uninstall it (since an exception is raised intentionally by this version 1.0.0 when calling the Custom Action which was set to happen on "Uninstall").
5. I created version 1.0.1 which fixes this problem (not updating the ProductVersion) - new TestDLL that does NOT cause exception when custom action is called.
6. I created the Patch for 1.0.0 to 1.0.1 and installed it.
7. I can now uninstall the program since 1.0.1 fixed the "crash/exception" caused when trying to uninstall 1.0.0.

So there you have it! it works!
I can say that you guys needed NO bug fixing, but most probably the problem happened either by installing different versions of Advanced Installer, or the "dangling" msiexec.exe processes found on my system.

Thank you for all your time and help.
Dashut.

BTW: The MessageBox now appears also for "install" and also for "uninstall" :-) I also tried to install version 1.0.0 on another client machine (only the MSI - NOT the Advanced Installer program), then tried to uninstall which causes an error, so I then run the Patch and now uninstall works! So this has been verified to work on another computer also.

Return to “Common Problems”