0
当加载dll文件使用.net反射(加载的文件描述是:Microsoft C运行时库),我得到运行时错误(R6034) 当加载dll,不使用C运行时库它将被成功加载, 可以我加载dll,使用C运行时使用.net反射,如果没有,那么如何捕获这个异常? 下面找到我的代码:.NET反射加载DLL文件给运行时错误(R6034)!
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;
}
}