0

Maybe duplicate with

Call a dll function from InstallAware or InstallShield

How can i call a method of a class of my dll at the end of the setup in installshield?

I have wrote something like the following code at the end of the Setup.Rul in my setup project and set the ComVisible of my dll and my class to true but i recieve this error yet :

"DLL function call crashed: ISRT._ DotNetCoCreateObject"

...
 
szDLLCompletePath = SUPPORTDIR ^ "MyDllName.dll";
 
szClassName = "MyDllName.MyClassName";
 
//The error occured at the following line
set Obj = DotNetCoCreateObject( szDLLCompletePath, szClassName, "");
 
If(! IsObject(Obj)) then
    MessageBox("Cannot load", SEVERE);
 
else
    Obj.MyMethodName(Parameters);
endif;

Note: I have added my dll as support file to my setup project.

Please tell me if there is any sample for this.

Community
  • 1
  • 1
M_Mogharrabi
  • 1,369
  • 5
  • 29
  • 57
  • Can you please show the code for your C# class. DotNetCoCreateObject creates an instance of your class. Do make sure it's not static. Also which line is it exactly crashing on? – Sourav 'Abhi' Mitra Mar 16 '14 at 14:22
  • @Abhi, Thanks for your reply. Yes your right, the problem is because of my code in my dll. because i have tried my setup with a simple dll and it works fine. But i need to do some complex works in my dll. I could not place my codes here however i could describe it for you: My code is for creating a user in a network. – M_Mogharrabi Mar 17 '14 at 04:43
  • Log to an external file in your c# code. Put Logging on every line. And execute from Installshield. Check where it fails. – Sourav 'Abhi' Mitra Mar 17 '14 at 04:48
  • I have loged in a registry key, and i found it has problem just at the beginning of method. I have a DLLImport and a struct in the class before my method.Do you think they could be the problem? – M_Mogharrabi Mar 17 '14 at 05:16
  • Comment out whatever you think is the problem and try. – Sourav 'Abhi' Mitra Mar 17 '14 at 05:20
  • I have tried your solution and i think the struct(which define the User_Info_1 to create new user in network) is the reason of problem.Note that i did'nt receive that mentioned error any more, but also the setup terminates before the welcome is shown. – M_Mogharrabi Mar 17 '14 at 08:37

0 Answers0