Unable to reference shared assembly in GAC [modified] Solved
-
This is from an example in Professional C#2008 from Wrox Chap 17, p491. Using a VS2008 C# class library project I've created a simple shared assembly. I've used the string name tool to create a name "sn -k mykey.snk" and used the VS Project | Properties | Signing tab to sign the assembly with this key. After building, by using idlview, I can view the key in the manifest. Opening a VS Command prompt to RunAs Administrator I've installed it using "gacutil /i SharedDemo.dll". But I can't seem to reference it from a VS2008 C# Console Application project. From Solution Explorer I right-click the solution and use Add Reference. I can find the assembly in C:\Windows\assembly using the Add Reference Browse tab but am unable to select it. The book says "... referenced in the same way as a private assembly..." I'm not trying any Delayed Signing, just to make a compile time reference. I tried starting VS2008 with RunAs Administrator but it made no difference. Any ideas appreciated. The assembly is in the GAC as shown by:
>gacutil /l SharedDemo
Microsoft (R) .NET Global Assembly Cache Utility. Version 3.5.21022.8 Copyright (c) Microsoft Corporation. All rights reserved.The Global Assembly Cache contains the following assemblies:
SharedDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c5bbc6da95e06b44, processorArchitecture=MSILNumber of items = 1
modified on Monday, July 19, 2010 10:02 AM
-
This is from an example in Professional C#2008 from Wrox Chap 17, p491. Using a VS2008 C# class library project I've created a simple shared assembly. I've used the string name tool to create a name "sn -k mykey.snk" and used the VS Project | Properties | Signing tab to sign the assembly with this key. After building, by using idlview, I can view the key in the manifest. Opening a VS Command prompt to RunAs Administrator I've installed it using "gacutil /i SharedDemo.dll". But I can't seem to reference it from a VS2008 C# Console Application project. From Solution Explorer I right-click the solution and use Add Reference. I can find the assembly in C:\Windows\assembly using the Add Reference Browse tab but am unable to select it. The book says "... referenced in the same way as a private assembly..." I'm not trying any Delayed Signing, just to make a compile time reference. I tried starting VS2008 with RunAs Administrator but it made no difference. Any ideas appreciated. The assembly is in the GAC as shown by:
>gacutil /l SharedDemo
Microsoft (R) .NET Global Assembly Cache Utility. Version 3.5.21022.8 Copyright (c) Microsoft Corporation. All rights reserved.The Global Assembly Cache contains the following assemblies:
SharedDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c5bbc6da95e06b44, processorArchitecture=MSILNumber of items = 1
modified on Monday, July 19, 2010 10:02 AM
I think you're doing it wrong. Don't try to reference the assembly in the GAC, just try to reference the assembly in the directory where you created it and the system will figure out the rest. That's what works for me. Your application shouldn't have to know whether or not the assembly is in the GAC.
-
I think you're doing it wrong. Don't try to reference the assembly in the GAC, just try to reference the assembly in the directory where you created it and the system will figure out the rest. That's what works for me. Your application shouldn't have to know whether or not the assembly is in the GAC.
You seem to be right. In my client console project I referenced the local copy of the shared assembly SharedDemo.dll which I was able to do. But if I rename the local directory the console client still runs OK which must prove it using the shared one in the GAC. Thanks