尝试调用托管代码DLL时Installshield安装程序 [英] Installshield setup crahses while trying to call managed code DLL

查看:98
本文介绍了尝试调用托管代码DLL时Installshield安装程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正面临一个紧急问题。对此的帮助将受到高度赞赏。



我创建了一个installshield项目。我已经使用在托管程序集中调用公共方法创建了一个自定义操作。 DLL中的代码是

Hi,

I am facing an urgent issue. A help on this will be highly appreciated.

I have created an installshield 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;        
        }
    }
}





------------ ---

问题:每当installshield尝试调用此方法MyFunc时,它无法找到依赖关系System.managment.dll并且崩溃了。我验证了由于这个问题设置崩溃,就好像我评论使用system.managment.dll的代码,只是返回一个硬编码字符串的东西工作正常。



在installshield中,我还将System.Management.dll添加为在ISClrwap表中创建的自定义操作的依赖项。我还在installshield的先决条件中添加了我已经下载的.Net Framework 4.0。



我已经搜索了很多表单但是无法找到解决这个问题的方法。



---------------
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.

推荐答案

您可以尝试实现 AppDomain.AssemblyResolve事件 [ ^ ]。

这样你可以确保 System.Management的正确版本.dll 在运行时加载。
You could try to implement the AppDomain.AssemblyResolve Event[^].
That way you can make sure that the correct version of System.Management.dll is loaded in runtime.


这篇关于尝试调用托管代码DLL时Installshield安装程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆