top of page
througdersbetenord

Copy a com dll to gac folder using gacutil tool



During execution (run-time) if the assembly is found to be signed and deployed in GAC the CLR automatically picks up the assembly from the GAC instead of the DLL referenced during design time in VS. In case the developer has deleted the original DLL or don't have it for some reason, there is a way to get the DLL file from GAC. Follow the following steps to copy DLL from GAC


I think the easiest way is to do it through the command line like David mentions. The only trick is that the .dll isn't simply located at C:\Windows\Assembly. You have to navigate to C:\Windows\Assembly\GAC\[ASSEMBLY_NAME]\[VERSION_NUMBER]_[PUBLIC KEY]. You can then do a copy using:




copy a com dll to gac folder




Easy way I have found is to open the command prompt and browse through the folder you mention until you find the DLL you want - you can then user the copy command to get it out. Windows Explorer has a "helpful" special view of this folder.


Open RUN then type %windir%\assembly\GAC_MSIL, this will open your dlls in folders' view you can then navigate to your dll named folder and open it, you will find your dll file and copy it easily


Opening this shortcut takes you to the System folder inside the GAC (which everyone should have) and has the wonderful side effect of letting you switch to a higher directory and then browsing into any other folder you want (and see the dll files, etc)


I didn't have it in my v2.0 folder. But I tried dragging & dropping the DLL into the C:\WINDOWS\Assembly folder as was suggested here earlier and that was easier and does work, as long as it's a .NET library. I also tried a COM library and this failed with an error that it was expecting an assembly manifest. I know that wasn't the question here, but thought I'd mention that in case someone finds out they can't add it, that that might be why.


But I don't have a VS2008 tool (i click start, all programs, and can only select VS2008). So I tried dragging the dll file to the GAC folder using explorer by - c:\windows\assembly but it won't allow me to drop it. How do I do this?


" First off, GACUTIL is part of the .Net SDK not the .Net Redistributible, therefore you are not licensed to redistribute that code.Secondly, .Net and the CLR were designed to mitigate the problems associated with sharing library code files that everyone calls DLL Hell, the GAC , if used improperly, reintroduces all the pitfalls that COM DLLs hadThe GAC makes xcopy deployment moot. If you're going to use the GAC, and since you can't use xcopy now, you should really be using a installation technology that was designed for end-user application installation.. like Windows Installer (MSI). MSI knows how to register assemblies with the end-user's GAC. Dont hack the installation APIs by using GACUTIL.GACUTIL is for developers not end-users. That's why it's in the SDK but not the Redistributable"


I've googled it and tried your suggestions. I don't want to reinstall 2008 at this time however I've downloaded the pro 90 day version but it is an image file so I paid for isobuster to extract the folders but i get a load of "Sector .... couln't be read" messages. Besides, would I have to uninstall the express version before installing the pro version - unfortunatly there isn't any documentation.


  • AnswerTo manually install a new DLL file into the GAC (NS6 physical path is %windir%\assembly\gac, NS7 uses %windir%\assembly\gac_msil): Stop all Altiris services

  • Stop IIS

  • Open Windows Explorer and navigate to the %WINDIR%\Assembly folder (this is not the physical path, but is a view into the combined GACs)Copy and Paste (Drag and drop) the new DLL file into the Assembly folder

Occassionally, this may encounter an error (due to the file being locked by some process that was not shutdown) which Explorer does not report back. Usually if the file is locked Explorer will tell you, but there are times where it does not. To workaround this:


The global assembly cache (GAC) provides a centralised, machine-wide storage location for .NET assemblies. When you add an assembly to the GAC, you allow it to be shared by many programs, rather than requiring a copy to be installed for each application.


By default, when you add a reference to a DLL to your project, the reference's "Copy Local" property is set to true. On building the solution, the DLL will therefore be saved into the folder containing the compiled program. The entire output folder can then be simply copied to the end-user's computer and executed, as all of the required assemblies are available. The downside to this approach is that each program deployed includes its own copy of the DLL. If the shared classes are updated to fix bugs or to implement new features, the DLL may need to be deployed to multiple locations to ensure that every program is using the latest revision.


The use of the global assembly cache for storing your shared assemblies has some drawbacks. One of the more important problems is that when your programs rely on assemblies being registered in the GAC, they become more difficult to deploy. Specifically, it is no longer possible to install your application simply by copying the output folder to the target machine. Another limitation is that assemblies may only be added to the cache if they are signed with a strong name key.


It is recommended that you only use the GAC for your own assemblies when it is absolutely necessary. Microsoft suggests that you should generally keep your assemblies within the application folder. However, there are several good reasons to use the GAC, including:


The Global Assembly Cache appears as a folder named "assembly" within the file system. The folder is found in the Windows folder (or WINNT folder depending upon the version of Windows in use). When browsed using Windows Explorer, the names, versions, public key tokens and other details of all of the installed assemblies are displayed.


If you are not using an installer, there are two easy ways to install an assembly to the GAC. These are using the .NET Global Assembly Cache Utility (gacutil.exe) or by copying the DLL using Windows Explorer. Although there are other ways to achieve the same results, I will describe these two variations in this article.


NB: You must have the relevant permissions to install and uninstall assemblies in the GAC. If you are using Vista, run the gacutil.exe tool using the Run as Administrator option. For copying using Windows Explorer, you must have write permissions on the GAC folder.


When working on a VS project that involves referencing Microsoft.SharePoint.dll, building the project causes Microsoft.SharePoint.Search.dll to be copied to my bin folder. Why is this? Okay, maybe it's just a bug, but I want to know the mechanism. (Thanks to SO, I know how to prevent this from happening, but I still want to find out why it happens in the first place.)


The binaries interact with each other and must be kept in the same folder for the assembly to work. In rare situations this is not possible (e.g. when installing the assembly to GAC), make use of the Session.ExecutablePath property to force the assembly to look for the winscp.exe in a different location.


The version of WinSCPnet.dll in the root of the package is .NET Framework build of the assembly. If your project targets .NET (Core) or if you use PowerShell (Core) 6/7, you have to use .NET Standard build of the assembly, which is located in the netstandard2.0 subfolder. The .NET Standard build has some minor limitations and cannot be used with COM.


Where the %WINDIR% is path to your Windows installation, what is typically C:\Windows or C:\WINNT. Note that you can keep %WINDIR% as this environment variable should be set on your system to point to the Windows folder. The Framework needs to be replaced by Framework64 to register the assembly for use from 64-bit applications.2 On 64-bit systems, you should generally register the assembly both for 32-bit (such as old versions of Microsoft Excel) and 64-bit applications. The is version of .NET framework to register the assembly with. It is recommended to use the latest available, what currently is v4.0.30319. You may however use any framework version from 2.0 (v2.0.50727) up. Note that framework 3.0 and 3.5 do not ship with RegAsm.exe. For these versions use RegAsm.exe from 2.0.


Method 1 : Using Visual Studio Command Prompt 1. Open up the visual studio command prompt or .Net command prompt. (You can find command prompt in program files -> Visual studio -> Visual studio tools). 2.Click to open command prompt then navigate to project folder eg: to navigate to any drive type drive name followed by colon (i.e. to navigate "D" drive type * D: and press on Enter button*). After navigating to a drive type "cd followed by any folder name" (i.e. cd Gacdemo and press on Enter button). Same way you can navigate to your own custom folder by using commands. 3.Go to the project folder using commands in visual studio command prompt 4.Once you are inside your project folder, Now let's create a strong name file by using following command as shown below. sn -k Gacdemo.snk You can replace "Gacdemo" with your own project name or any name as per your requirement. Type "sn -k Gacdemo.snk" then press on Enter button.This will create Gacdemo.snk (Strong Name Key File) in that folder. Strong name file consist of unique identity or private key with its version number, text name, public key, culture information and a digital signature.


1st Method Just drag and drop/ CopyPaste an assembly to an assembly folder. To find an assembly folder first you need to check your windows installation drive, In my case my windows is installed in "C-drive" so its "C" drive C:\WINDOWS\assembly. 2ff7e9595c


0 views0 comments

Recent Posts

See All

Comments


bottom of page