How to copy from the GAC

If you’re not a .NET developer, you probably don’t care.  If you are a .NET developer, you’ve likely had some case where you’ve got an assembly installed on your development machine, but when you deploy via XCOPY or some other means, the target server doesn’t have that DLL and you get an error.  Today I found the trick to copying out of the GAC.

The trick is, you can’t use Windows Explorer.  Open an administrative command prompt (Right-click, run as Administrator) and CD to C:\Windows\Assembly.  This directory is not how it appears when viewed from Windows Explorer.  It actually contains a number of directories organized by the type of DLLs it contains.

Most .NET DDLs are MSIL compiled and thus are contained in the GAC_MSIL directory.  The DLLs aren’t in there either, instead they’re in a sub-sub-directory, the first being the name of the DLL without the “.dll” extension and the second being what looks like a version number/public key token (e.g. Microsoft.SqlServer.SqlClrProvider.dll is contained in C:\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.SqlClrProvider\

The easiest way to find your particular DLL is to use the DIR command repeatedly.  You then want to use the COPY or XCOPY commands to copy the DLL somewhere else.

Happy Coding!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: