Wednesday, March 7, 2007

Copy a DLL from GAC to your own folder

Have you ever tried copying a dll from GAC to your own folder.

Today I was trying to work with BSM score cards in ASP.NET application (without using sharepoint server). I need to create a control of type 'Microsoft.PerformanceManagement.Scorecards.WebControls.ScorecardCtrl ' and I was getting an error here (Assembly reference error).

when I opened C:\windows\assembly (Location of GAC) I can see Microsoft.PerformanceManagement.Scorecards.WebControls.dll file. But there is no way to access this dll in my prj (web application). So I need to copy this dll to my working folder.

Its not possible to copy directly from c:\windows\assembly directory in GUI mode.

What we can do is go to cmd prompt
c:\cd windows
c:\windows\cd assembly
c:\windows\assembly\cd GAC
c:\windows\assembly\GAC

From assembly folder move to the folder where the required dll is present. For ex. Microsoft.PerformanceManagement.Scorecards.WebControls is present in a folder named 'Microsoft.PerformanceManagement.Scorecards.WebControls'

c:\windows\assembly\GAC\cd Microsoft.PerformanceManagement.Scorecards.WebControls
c:\winodws\assembly\GAC\Microsoft.PerformanceManagement.Scorecards.WebControls\dir *.*

now using ms-dos 'copy' command, copy the dll to your folder.
syntax: copy 'source file name' 'destination path & optional file name'


For ex: to copy system.web dll do the following:
c:\windows\assembly\GAC\system.web\copy 1.0.5000.0__b03f5f7f11d50a3a "c:\Chittydir"
(where 1.0.5000.0__b03f5f7f11d50a3a is the file name. It need not be the same everywhere. Pls check.)

Enjoy....


Reference for using BSM score cards in asp.net:
http://www.iantien.com/downloads/BSMSamples/BSM-ASP.htm

No comments: