开发者

Application fails when dll added to GAC, okay otherwise

开发者 https://www.devze.com 2023-02-04 15:10 出处:网络
I have an application which r开发者_Python百科eferences some .Net dlls and is used to convert a file between different formats. If I add a reference to the .dll file, my application runs without probl

I have an application which r开发者_Python百科eferences some .Net dlls and is used to convert a file between different formats. If I add a reference to the .dll file, my application runs without problem.

However, if I add the dll to the GAC, and reference it from there, my application fails during run time, due to a parsing error. The physical location of the dlls are unchanged.

I have several configuration files which are accessed via environment variables, and these are used to parse input files.

Any ideas what might be the problem?

    private static string FILE_CONFIGURATION = "configuration.xml";

    string configurationPath = "c:\\temp\\CDXMLViewerDist\\" + FILE_CONFIGURATION;
    System.Environment.SetEnvironmentVariable(translator.domains.XMLDomainConfiguration.FILE_CONFIGURATION_PATH, configurationPath);
    System.Environment.SetEnvironmentVariable(translator.domains.XMLDomainConfiguration.DOMAIN_CONFIGURATION_PROPERTY_KEY, typeof(XMLDomainConfiguration).FullName);


String strPath = "C:\\temp\\out.cdxml";


CDXMLReader reader = new CDXMLReader();
reader.Read(strPath);  // Runs fine if reference dll as file, throws exception if via GAC


The problem was due to an attempt to instantiate an object using

object o = Activator.CreateInstance(assemblyName, fullyQualifiedTypeName);

When accessing via the GAC, I needed to use a fully qualified assembly name rather than just the assembly name e.g.

"AssemblyName, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=abcdef1234567890"

0

精彩评论

暂无评论...
验证码 换一张
取 消