开发者

Why is my assembly not visible in "Add Reference > .Net" when installed to the GAC?

开发者 https://www.devze.com 2023-02-13 03:01 出处:网络
Just have a quick question about the GAC I created an assembly Awesome.DLL. Had it signed, then installed into the GAC:

Just have a quick question about the GAC

I created an assembly Awesome.DLL. Had it signed, then installed into the GAC:

C:\MyApps\Awesome\Awesome\Awesome\bin\Release>sn -k Awesome.snk
Microsoft (R) .NET Framework Strong Name Utility  Version 4.0.30开发者_JS百科319.1 
Copyright (c) Microsoft Corporation.  All rights reserved.

Key pair written to Awesome.snk

C:\MyApps\Awesome\Awesome\Awesome\bin\Release>gacutil /i Awesome.dll 
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.1 
Copyright (c) Microsoft Corporation.  All rights reserved.

Assembly successfully added to the cache

C:\MyApps\Awesome\Awesome\Awesome\bin\Release>gacutil /l Awesome.dll 
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.1 
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:

Number of items = 0

My problem:

Awesome.DLL is not found in C:\Windows\Assembly or any of the sub folders. It is found, though in C:\WINDOWS\Microsoft.NET\assembly\GAC_MSIL\ I guess because of this, I am not able to see Awesome.DLL from Add Reference > .Net.

Why does it not install to C:\Windows\Assembly\? How can i point to that location instead?


Your assembly is installed to C:\WINDOWS\Microsoft.NET\assembly\ instead of C:\Windows\Assembly\ because it is a .Net 4.0 assembly and the .Net framework version 4.0 has a new separate GAC in that location. The GAC located at C:\Windows\Assembly\ contains only .Net 2.0 - 3.5 assemblies. (see .NET 4.0 has a new GAC, why?).

The list of assemblies found in Visual Studios "Add Reference -> .Net." dialog is not simply a list of assemblies found in the GAC (notice that most of the entries in that list aren't found in the GAC either).

For information on how to add your assembly to this list see the following article (specifically the "To display an assembly in the Add Reference dialog box" section):

  • How to: Add or Remove References in Visual Studio

Note that the registry key used for this is different for different versions of Visual Studio.


I've created a tool which is completely free, that will help you to achieve your goal. Muse VSReferences will allow you to add a Global Assembly Cache reference to the project from Add GAC Reference menu item.

Hope this helps.


Check your project properties under vs2010 Project menu: i've seen this were the project is ".NET Framework 4 Client Profile" and the assembly is ".NET 4 Fraemwork". solution : Change the project to ".NET framework 4" profile

0

精彩评论

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