views:

24

answers:

1

Hi All, when load dll file using .net reflection(the loaded file description is : Microsoft C Runtime Library), I got Run time error (R6034) when load dll that not using C runtime library it will be loaded successfully, can I load dll that using C runtime using .net reflection, if not, then how to catch this exception ? Find my code below:

    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;
    }
}
A: 

Did you install the VC_Redist x86 or 64 bit that come with the compiler you used to build your DLL? I think you forgot to deploy that on your machine or you forgot the include the manifest to your DLL. This is essential for C/C++ apps compiled with VS2005 or newer.

jdehaan