Running .dll Custom Action - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

jojo83
Posts: 4
Joined: Thu May 20, 2010 4:29 pm

Running .dll Custom Action

Hey all. Im having some issues running my custom attached action. I created myself as well as used the wizard to create it. Ive had some success using a vb script, but would like to change it to a .net c# .dll. So far I have created an dll with a static method. When adding the dll, the function list is no filled. It is unclear how to manually add the function signature, or if the list is not filled, then the function would not be able to be called. So my questions is, what are the dll requirements that would allow me to get this working correctly? I prefer if the list is available, allowing me to choose the method to call.
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Running .dll Custom Action

Hi,

For .NET DLL files you can use our predefined ".NET Installer Class Action" custom action. Here are more details about the configuration of this custom action parameters.

You cannot add the DLL as a simple attached or installed custom action, because as you have already experienced it will not be correctly loaded.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jojo83
Posts: 4
Joined: Thu May 20, 2010 4:29 pm

Re: Running .dll Custom Action

Ok So I think I have where to declare the .net assembly somewhat figured out. But I have some more questions. What my main task is to bring a property, that points to a installed folder path. send that to the .net .dll, and have the path adjusted, and use the new value in my desktop shortcuts. I had this somewhat working using a vb script, and a PropertySource(USER_DIR) associated with a formatted text(the folder). Putting the PropertySource in the Cost Finalize will substiture the PropertySource name with the path in the shortcuts as I wanted. Just the script did not work on all test platforms.

On the .net path, Ive removed the property source, and in .net assembly setup, pass in the User defined Property [USERDIR] as an Action Argument. it is mapped to the folder [MYFOLDER]. Ive implemented the install method(from the Installer class),passed in the argument and placed my call here to edit the path. But during install I have two problems, one is if dll action is in cost finalize, I get a error popup telling me the error dialog is bit is set. just like http://www.advancedinstaller.com/forums ... =2&t=10722

If I follow the above instructions I can get past the error, though the value of the [USERDIR] does not get resolved to a path, rather is the literal "[MYFOLDER]";
My questions would be, what is the appropriate installation sequence location to accomplish what I want. Do I need the ProperySource to accomplish this?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Running .dll Custom Action

Hi,

You can find a .NET Installer Class Action tutorial here. However, please note that this type of custom actions cannot set installer properties. Only VBScript and Win32 DLLs can. The User Guide contains a sample C++ DLL custom action which may help you.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jojo83
Posts: 4
Joined: Thu May 20, 2010 4:29 pm

Re: Running .dll Custom Action

So Ive finally got around to learning enough c++ to implement what I need done in a .dll, following the instructions above. Thanks for that, as it was very helpful. So my questions now are the following.
What type of custom action is appropriate for modifying the property, whose new value I want to be added to the shortcuts. Again the property is already set in the shorcuts, but I need the value adjusted. Seems as attached custom action is the way to go, I say that because I think the installed custom action needs to write the .dll to a location first before calling, and at the moment am not clear on when this happens in relation to when the shortcuts are created.
How is the best way to return or set the new property value. As I followed the above example, I thought I could use the MSI setProperty function in the dll call to set my new value. The instructions to how to set this new value are not clear to me yet. Using the "Call standard dll" option allows me to set a return value to a property, which looks to me as if I need to pass in the Property by reference. How does this relate to the MSIHandle that is passed in the example, which, I based my dll on. I was under the impression I could read the property from the MSIHandle object, modify it and set the new value. Using the attached custom action, doesnt have a dialog for setting return values, so Im guessing this is not the way to go?
Also where in the installation process should I place my action that will allow me to set the property correctly before the shortcuts are created? Wow I have alot of questions. My apologies for all these. And truly am appreciative of all help I can get. TIA.
jojo83
Posts: 4
Joined: Thu May 20, 2010 4:29 pm

Re: Running .dll Custom Action

So looks like I figured it all out. I am using a Attached custom action in the Cost Finalize section of the installer sequence. At first what was strange is that the function name was not being loaded, though I had .def file. I kept getting I think it was 1723 errors. So I kinda figured that the method from the C++ dll was not being exported correctly. I added the LIBRARY libnamehere line and still nothing. Then tried the __declspec( dllexport ) in front of my function. This allowed the the function name to be exported correctly. The function name now displayed is ?HandleUserDir@@YGIK@Z, which is somewhat alarming but worked correctly. I did utilize the MsiSetProperty to reset the new value of my property that was passed in. Which is alot of work just to double slash a path. But my application needs it so ok. So hopefully this helps others trying to load a custom action .dll. Use the above export on your function if your installer is not loading the function name. Worked for me. Thanks for the views and the direction Cosmin.

Return to “Common Problems”