|
Almost everything about writing class libraries in C# is easy except for one thing: using the global assembly cache. For about two years I ducked and
avoided the issues related to sign and register class libraries (assemblies) with the global assembly cache (GAC), but I have finally given in and figured out how to do
things correctly. When you register a class library with the GAC you get automated versioning control, and path management (no more searching for DLLs), and a lot less
headaches try to make things work.
There are two main challenges facing a developer who wants to register their assembly with the GAC:
(1) Strong signing of the assembly
(2) Calling GACUtil.exe to register the assembly with the cache.
What is a bit strange to me was that the Visual Studio IDE (except for express versions) only helps with the first step: signing
of the assembly. You just need to select the "Sign the Assembly" check box in the "signing" tab of the project configuration. Where it says "Choose a strong name
file", you pull down to "new". You don't have to provide a password to get up and running, and if security is not a concern.
The next step has to be done either manually or as a post-build step. Not very elegant. To make matters worse, the GACUtil.exe, is not easily found. It is most likely
found at: C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\gacutil.exe (as well as C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin but I trust that path less).
I guess once you find it you don't care so much, but if you want to distribute source code and project files for plug-ins like me, it becomes a bit of kludge to hard-code
one path or the other.
So in the end my post-build step looks like this:
"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\gacutil.exe" -I "$(TargetFileName)"
Anyway, I hope this helps some people out there. For more information here are some relevant articles online:
|