简体   繁体   English

.NET 4.0应用程序没有从GAC中提取DLL

[英].NET 4.0 app not pulling DLL from GAC

I have a v4.0 assembly that is both in the GAC (4.0 location) for runtime use and in a location on disk for designtime use. 我有一个v4.0程序集,它在GAC(4.0位置)中供运行时使用,在磁盘上的位置供设计时使用。 I have the designtime DLL's location set in the registry so that I can add it via Add Reference in Visual Studio. 我在注册表中设置了设计时DLL的位置,以便我可以通过Visual Studio中的“添加引用”添加它。

I also have a service that is using this DLL. 我也有一个使用此DLL的服务。 I added it via Add Reference and can compile without issue while referencing its classes. 我通过添加引用添加它,并且可以在引用其类时进行编译而没有问题。 However, when I run my service, it doesn't pull the DLL from the GAC, and I get an error that the service can't find a class in the GACked DLL. 但是,当我运行我的服务时,它不会从GAC中提取DLL,并且我收到错误,该服务无法在GACked DLL中找到类。 I can change "copy local" to true and it will work just fine, but that defeats the purpose of having the DLL in the GAC. 我可以将“copy local”更改为true,它可以正常工作,但这会破坏在GAC中使用DLL的目的。

Any suggestions on how to troubleshoot? 有关如何排除故障的任何建议?


I can add as reference to a new console app and access the object. 我可以添加作为新控制台应用程序的参考并访问该对象。 Not sure what the issue is with the service. 不确定服务的问题是什么。


It may not be finding the type.. but I can reference the type from the console app (using the GACked assembly), so I'm not sure why it can't find it when running the service. 它可能找不到类型..但我可以从控制台应用程序引用类型(使用GACked程序集),所以我不确定为什么它在运行服务时找不到它。

You will need to add the assembly under the system.web tag in the machine.config 您需要在machine.config中的system.web标记下添加程序集

<system.web>
    <compilation>
        <assemblies>
            <add assembly="YOUR_DLL_NAME, Version=1.1.0.0, Culture=neutral, PublicKeyToken=YOUR_KEY_TOKEN" />  
        </assemblies>
    </compilation>
</system.web>

Depending on your setup, the configuration file can be found: C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\Config\\machine.config or C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\Config\\machine.config 根据您的设置,可以找到配置文件:C:\\ Windows \\ Microsoft.NET \\ Framework64 \\ v4.0.30319 \\ Config \\ machine.config或C:\\ Windows \\ Microsoft.NET \\ Framework \\ v4.0.30319 \\ Config \\ machine.config中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM