如何从GAC加载程序集

如何从GAC加载程序集

本文介绍了C#:如何从GAC加载程序集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有mycomp.myassembly.dll在GAC,但加载和LoadFrom抛出文件未发现异常,并LoadWithPartialName返回null。我做了以下内容:

I have "mycomp.myassembly.dll" in GAC but Load and LoadFrom throws file not found exception and LoadWithPartialName returns null. I'm doing the following:

    AssemblyName name = new AssemblyName();
    name.Name = "mycomp.myassembly.dll";

    Assembly assembly = Assembly.Load(name);

失败,FileNotFound的mycomp.myassembly.dll文件,以及

fails with FileNotFound for mycomp.myassembly.dll file, and

    Assembly assembly = Assembly.Load("mycomp.myassembly.dll");

失败,完全一样的消息。

fails with exactly the same message.

我仔细检查该程序集是在GAC(甚至没有GACUTIL /如果它再次)和它在其他情况下的工作,我只是无法加载它自己。

I double checked that assembly is in GAC (and even did gacutil /if for it again) and it does work in all other cases, I just unable to load it myself.

我在做什么错在这里?难道我错过了什么?

What am I doing wrong here?Do I miss something?

推荐答案

您是否尝试过使用完全限定的程序集名称? (例如:ycomp.myassembly.dll,版本= 1.0.2004.0,文化=中性公钥= 8744b20f8da049e3

Have you tried using the fully qualified assembly name? (e.g. "ycomp.myassembly.dll, Version=1.0.2004.0, Culture=neutral, PublicKeyToken=8744b20f8da049e3")

这篇关于C#:如何从GAC加载程序集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 05:56