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.

Installshield setup crahses while trying to call managed code DLL

1 reply to this topic


  • Full Members
  • 1 posts

Posted 03 January 2015 - 13:52

I am facing an urgent issue. A help on this will be highly appreciated.
I am working on installshield 2009 installed on virtual machine. I have created an installshield basic msi project. In that I have created a custom action using "Calling public method in a managed assembly". code in the DLL is 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;
namespace ClassLibrary1
public class Class1
public string MyFunc(int flag)

System.Management.ManagementClass mangnmt = new ManagementClass("Win32_LogicalDisk");
ManagementObjectCollection mcol = mangnmt.GetInstances();
string result = "";
foreach (ManagementObject strt in mcol)
if (Convert.ToInt32(strt["MediaType"]) != 12) { continue; }
if (Convert.ToInt32(strt["DriveType"]) != 3) { continue; }
if (Convert.ToString(strt["Name"]).ToLower() != "c:") { continue; }
result += "VolumeSerialNumber : " + Convert.ToString(strt["VolumeSerialNumber"]) + Environment.NewLine;
result = Convert.ToString(strt["VolumeSerialNumber"]);
if (!String.IsNullOrEmpty(result)) break;

return result;

ISSUE : Whenever installshield tries to call this method MyFunc,It is not able to find dependency System.managment.dll and it crashes. I verified that the setup crashes due to this issue only as if I comment the code that is using system.managment.dll and simply returns a hard coded string things works fine.
In installshield I have also added System.Management.dll as dependency to custom action created in ISClrwap table. I also added in installshield prerequisites i have downloaded .Net Framework 4.0.
I have searched lot of forms but not able to figure out the solution to this issue.


  • Moderators
  • 1,447 posts

Posted 08 January 2015 - 20:19

Your .NET dll probably has several dependencies beyond System.managment.dll, at the very least System.Collections.dll or whatever the name of the dll that hosts generics is. The use of Linq and perhaps also Text could trigger further requirements (you should perhaps remove Using System.Linq since it doesn't appear used?).


In general I wouldn't recommend using .NET custom actions due to their extensive runtime requirements. Beyond missing dlls you can also face a situation where the whole .NET runtime version you are targeting is missing or disabled.


You would be better off using Installscript or VBScript - both have simple runtime requirements - especially VBScript since the Windows Installer Engine host its own scripting runtime. The Installscript runtime is running from a binary table dll in either a sand-boxed or native fashion (don't know exactly how). This is more reliable than using .NET custom actions (though Installscript versions prior to version 12 had some common runtime bugs that should be resolved now).


Apart from Installscript and VBScript native mode DLLs written in C++ have the simplest runtime requirements, and isn't that much harder to write than Installscript if you are used to C++ code in the first place. They can also be debugged with full step-through if you show a message box from the custom action and attach the debugger with the dll compiled in debug mode. Search installsite.org for more details on this if it is interesting - I wrote some step by step instructions at some point.


Update: check the "Debugging Custom Actions" section here: http://www.installsi...htm#cadebugging

Edited by Glytzhkof, 09 January 2015 - 17:35.

-Stein Åsmul