2011 Software releases
Learn about the 2011 versions of some of Autodesk’s Digital Entertainment Creation tools.
Theme color:
  • 1/1
You are here: Homepage /  Blogs /  The 3ds Max SDK Blog / .NET Class Libraries, Strong Signing, and the Global Assembly Cache
.NET Class Libraries, Strong Signing, and the Global Assembly Cache
Posted: Jul 29, 2009
Category:
Social Media:
Bookmark and Share
 

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:

In order to post any comments, you must be logged in!