当使用.net反射加载dll文件时(加载的文件描述是:Microsoft C运行时库),我得到运行时错误(R6034) 当加载不使用C运行库的DLL时,它将被成功加载, 我可以使用.net反射加载使用C运行时的dll,如果没有,那么如何捕获此异常? 在下面找到我的代码:
class ReverseDLL
{
private Assembly assembly;
private AssemblyDescriptionAttribute desc;
private AssemblyTitleAttribute title;
private AssemblyCopyrightAttribute copyRight;
public string getCopyright(string path)
{
try
{
assembly = System.Reflection.Assembly.LoadFrom(path);
}
catch { Console.WriteLine("(private message)Class ReverseDll : Couldn't load dll"); }
try
{
string verInfo = assembly.GetName().Version.ToString();
desc = (AssemblyDescriptionAttribute)
AssemblyDescriptionAttribute.GetCustomAttribute(
assembly, typeof(AssemblyDescriptionAttribute));
title = (AssemblyTitleAttribute)
AssemblyTitleAttribute.GetCustomAttribute(
assembly, typeof(AssemblyTitleAttribute));
copyRight = (AssemblyCopyrightAttribute)AssemblyCopyrightAttribute.GetCustomAttribute(assembly, typeof(AssemblyCopyrightAttribute));
Console.WriteLine("Class ReverseDll , signature: " + copyRight.Copyright.ToString());
}
catch
{
this.copyRight = new AssemblyCopyrightAttribute("");
Console.WriteLine("(private message)Class ReverseDll : reflection not able to pull the needed data ");
}
return copyRight.Copyright;
}
}
答案 0 :(得分:0)
您是否安装了用于构建DLL的编译器附带的VC_Redist x86或64位?我想您忘记在机器上或forgot the include the manifest to your DLL部署它。这对于使用VS2005或更新版本编译的C / C ++应用程序至关重要。