cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
DanCla
Level 5

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
Labels (1)
0 Kudos
(4) Replies
MichaelU
Level 12 Flexeran
Level 12 Flexeran

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.
0 Kudos
Christopher_Pai
Level 16

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.
0 Kudos
DanCla
Level 5

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?
0 Kudos
Christopher_Pai
Level 16

0 Kudos