Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Parameter to the .net DLL


18 replies to this topic

aditya1685

aditya1685
  • Full Members
  • 31 posts

Posted 16 September 2011 - 10:08

Hi,

Can anyone suggest me, how to pass parameter to the .net DLL at runtime. My scenario is I have one Dialog in which there are two radio buttons, when user selects either of the radiobutton a .net dll is installed in the system. I want when the Dll is copied into the system, some parameter need to be passed into it. After that installation need to be occur. I am working on basic MSI project.

Thanks
Aditya

Nachtmahr

Nachtmahr
  • Full Members
  • 13 posts

Posted 16 September 2011 - 15:30

You can call the .NET DLL via the " New Managed Code " Custom Action in the Custom Actions and Sequences View.
If you added the action click on it and select your assembly file in the property editor. After that click on "Methodsignature" and select your Method you want to call. Check the Checkbox "Use user-defined methodsignature" and pass your parameters.
This should do the trick

aditya1685

aditya1685
  • Full Members
  • 31 posts

Posted 17 September 2011 - 10:38

Thanks, But I am not able to understand where you are telling me to add custom action. In custom Action and sequence, I am using Custom Action Wizard, in that wizard I am selecting "call a public method in managed assembly" after that I am selecting my dll and pass the parameter to it.... I have called this custom action on the install finish button event as DoAction . If this is the same you are talking about then it doesn't work.

aditya1685

aditya1685
  • Full Members
  • 31 posts

Posted 20 September 2011 - 06:32

Hi,

My problem has been resolved, now I am able to pass parameter. But, in custom action wizard if I select the dll location option as binary table i.e. from the local machine it works fine. However, if I give the option intall from project in which I specify the location of my dll in my project which is Program files, it doesn't work. Please help me.

Thanks
Aditya

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 20 September 2011 - 09:58

If you want to call a file that your setup installs, you can do so only after the file has been installed (obviously). So where in the sequence did you schedule the custom action, and did you select "deferred" instead of "immediate"? What's the error message you get? Did you get any build warnings? Did you run validation on the built setup?

aditya1685

aditya1685
  • Full Members
  • 31 posts

Posted 20 September 2011 - 10:21

Hi Stefan,

As I am new to installshield, I am not sure how to make custom action in sequence. I have created a custom action using custom action wizard, in the wizard I am using location option as "install with the produc"t, In-script execution as "Deferred execution", Install execute sequence as "after installfiles" and install execute condition is equal to some condition.
When I build the project one warning comes which says .netfamework is required. For validation I have used Perform validation using "Installshield validation suite for windows®7, it says dlls you are using must be signed. When I run the installer my installer finished without installing anything on the system.

Thanks
Aditya

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 20 September 2011 - 10:46

So far that's looking okay. Where is that assembly being installed to? In the GAC? As a test, try changing the custom action settings to "immediate" and "after InstallFinalize" to see if that helps.
For vaidation please also use the "full msi" validation suite.

aditya1685

aditya1685
  • Full Members
  • 31 posts

Posted 20 September 2011 - 11:39

Hi Stefan,

Thanks for your reply.

I tried what you have suggested, but it doesn't work sad.gif My dll file will install inside the program files folder. Please let me know if you need more information from your side.

Thanks
Aditya

aditya1685

aditya1685
  • Full Members
  • 31 posts

Posted 21 September 2011 - 05:12

Hi Stefan,

Thanks for your reply.

I tried what you have suggested, but it doesn't work sad.gif My dll file will install inside the program files folder. Please let me know if you need more information from my side.

sorry for the typo error in the previous reply.

Thanks
Aditya

aditya1685

aditya1685
  • Full Members
  • 31 posts

Posted 21 September 2011 - 06:07

Hi Stefan,

Just for your information, I have created one dummy .net dll in which I have print the "hello world" when some parameter is pass to it and it is working fine with all the condition like location option as "install with the produc"t, In-script execution as "Deferred execution", Install execute sequence as "after installfiles" and install execute condition is equal to some condition.

Thanks
Aditya

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 21 September 2011 - 18:04

So the test DLL works, but the real DLL fails from installed file but works from Binary table? Could it be some missing dependency?

aditya1685

aditya1685
  • Full Members
  • 31 posts

Posted 22 September 2011 - 05:27

Thanks Stefan

Yes, test Dll also works from Binary table. I did more research on my custom action and found that parameter value which I am passing is not compatible with the data type of my method parameter. However, the same parameter works fine in my previous installer which was build in visual studio. Basically, we have one Installer.vb class in our DLL in which there is a method " Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)". When I create custom action in visual studio, I use this method and pass the CustomActionData as "/machine="[SCOMVERSIONVALUE]" /mp="A.B.C" /targetdir="[INSTALLDIR]\" it works fine, but the same value doesn't work in installshield, it says it can not convert (system.string into System.Collections.IDictionary).

Thanks
Aditya

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 22 September 2011 - 16:49

I'm not sure about that, but you could open both .msi files in direct edit mode (or in a msi table editor such as InstEd) and compare the custom action settings. Then you can adjust them in your InstallShield project appropriately, either in the Custom Action UI or in the Direct Editor.

aditya1685

aditya1685
  • Full Members
  • 31 posts

Posted 23 September 2011 - 12:35

Hi Stefan,

Thanks again for your reply.

To resolve this issue I have created one more method in my dll which takes parameter as string and inside that method, I have extracted the key,value pair from the string and store it in a dictionary. After this I called my Install method as Install(dict). Now I am not getting that error, but this time it says:

Loading Assembly Microsoft.EnterpriseManagement.OperationsManager
InstallShield: Couldn't resolve assembly by name Microsoft.EnterpriseManagement.OperationsManager, Version=6.0.4900.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
InstallShield: Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EnterpriseManagement.OperationsManager, Version=6.0.4900.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

However, I have included these namespaces in my dll, still I am not able to understand why it is throwing such kind of error.

Thanks
Aditya

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 26 September 2011 - 14:50

I'm sorry, I'm not a .NET expert. Maybe someone else can help?

aditya1685

aditya1685
  • Full Members
  • 31 posts

Posted 27 September 2011 - 04:10

Thanks Stefan smile.gif

aditya1685

aditya1685
  • Full Members
  • 31 posts

Posted 27 September 2011 - 11:09

No problem Stefan smile.gif

I was looking for forum for similar kind of problem and I found one forum where similar kind of issue is discussed. In that post they have recommended to first create a setProperty before creating a DeferredAction and to specify some CustomActionData. However, I have tried doing that, I have created a SetProperty after that I have created my DeferredAction but, I am not able to understand how to set those customactiondata and where I need to set those. This is a sample of code they have mentioned in the forum:

#customactions.dll="[#customactions.dll]" name="NativeStorage" connstring="TestConnectionString" filename="{ProgramFilesFolder}\Serveron\SA View\Serveron Client.config" encrypt="true"


Forum Link: http://community.fle...ad.php?p=462313

It would be great if you can give me idea on this.

Thanks
Aditya

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 28 September 2011 - 14:27

That CustomActionData procedure is required if you want to get the property value by calling MsiGetProperty inside your DLL. I don't think it's applicable to .NET custom actions.

aditya1685

aditya1685
  • Full Members
  • 31 posts

Posted 29 September 2011 - 05:15

Thanks Stefan smile.gif