This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Calling function inside C# DLL
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 08, 2008
08:19 AM
Calling function inside C# DLL
I am currently working on a project that requires me to:
1. Get a string from the user.
2. Use a function inside a DLL written in C# to modify that string.
function ( )
3. Write the modified string into a .config file.
I've had no problem implementing #1 and #3, but I have not been able to implement #2. I have tried to implement a custom action that calls a standard DLL and I get a "the dll being called encountered a problem" error. I have also tried using the UseDll function inside a installscript custom action and I get a "unable to load a dll" error. I am implementing this in a basic msi project using InstallShield 2008. Any ideas or guidance will be greatly appreciated.
Thanks
1. Get a string from the user.
2. Use a function inside a DLL written in C# to modify that string.
3. Write the modified string into a .config file.
I've had no problem implementing #1 and #3, but I have not been able to implement #2. I have tried to implement a custom action that calls a standard DLL and I get a "the dll being called encountered a problem" error. I have also tried using the UseDll function inside a installscript custom action and I get a "unable to load a dll" error. I am implementing this in a basic msi project using InstallShield 2008. Any ideas or guidance will be greatly appreciated.
Thanks
(4) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 08, 2008
11:02 AM
Managed Code DLLs, such as those written in C#, cannot be loaded through conventional C++ DLL loading means. From InstallScript code you can load them with DotNetCoCreateObject / CoCreateObjectDotNet. In InstallShield 2009, Basic MSI projects also support calling them in "Managed Code" custom actions.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 08, 2008
11:06 AM
A dash of single responsibility principal would help here.
For #1, just use an MSI dialog; no custom action is required
For #2, a custom action may be required
For #3, I'm guessing config is .config ( xml ) so use XML File Changes view.
For #2, how complex is the customization? Does it require managed code? If so, I'd write a DTF CA reads the property the user inputted and writes it to another property that the XML file changes can use to write out to the config file.
For #1, just use an MSI dialog; no custom action is required
For #2, a custom action may be required
For #3, I'm guessing config is .config ( xml ) so use XML File Changes view.
For #2, how complex is the customization? Does it require managed code? If so, I'd write a DTF CA reads the property the user inputted and writes it to another property that the XML file changes can use to write out to the config file.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 08, 2008
12:40 PM
Thanks for the quick replies,
Let me explain things a little better, for the second requirement, once I get a string from the user I am going to pass this string to a public method of a class that resides inside the C# DLL. This method will return a modified string, which will get written to a .config(XML) file. I don't know what is a DTF custom action could you please explain?
Let me explain things a little better, for the second requirement, once I get a string from the user I am going to pass this string to a public method of a class that resides inside the C# DLL. This method will return a modified string, which will get written to a .config(XML) file. I don't know what is a DTF custom action could you please explain?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 08, 2008
01:51 PM
Read:
http://blog.deploymentengineering.com/2008/03/installshield-2009-beta-part-ii-managed.html
and then read:
http://blog.deploymentengineering.com/2008/05/deployment-tools-foundation-dtf-custom.html
Basically you'd write a DTF custom action in C# that encapsulates your existing class.
http://blog.deploymentengineering.com/2008/03/installshield-2009-beta-part-ii-managed.html
and then read:
http://blog.deploymentengineering.com/2008/05/deployment-tools-foundation-dtf-custom.html
Basically you'd write a DTF custom action in C# that encapsulates your existing class.