none
.NET 4 gacutil on production server RRS feed

  • Question

  • Since you can no longer use the 2.0 Framework Configuration tool to add .NET 4.0 assemblies to the GAC, how do you add .NET 4.0 assemblies to the .NET 4 GAC? From the looks of it, the full .NET 4 installation DOES NOT install a version of gacutil.exe. It seems that that is part of the SDK.

    But there is more! You can't install the SDK without installing VS2010 on the machine. That is a no-no within a production environment!

    So, how do you register the assembly now on production machines?

    Friday, April 16, 2010 1:15 PM

Answers

  • To clarify Figo's answer, the following is the solution that worked perfectly for me. I have VS2010, but I guess if you installed the Windows SDK for Windows 7 and .NET Framework 4 you'd have gacutil in the same location too.

    I copied the following files from  C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools   

    to a folder on the server containing the DLLs I wanted to install:

    • gacutil.exe
    • gacutil.exe.config
    • 1033\gacutlrc.dll     (can be placed in the same dir as gacutil.exe on the server)

    Then I ran:    gacutil.exe -I <dllfilename>     to install the DLLs in the GAC.

    Note: if you don't include gacutlrc.dll in the same directory as gacutil.exe on the server, when you run gacutil.exe it doesn't actually 'do' anything - just exits without error.

    Hope that helps.

     

    • Marked as answer by Figo Fei Tuesday, June 1, 2010 5:53 AM
    Friday, May 28, 2010 4:24 PM
  • Hi Matt

    We must copy the gacutlrc.dll (in subfolder 1033) with the gacutil.exe as its extension.

    Thanks.


    Figo Fei
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com 


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Figo Fei Monday, May 24, 2010 7:38 AM
    Wednesday, May 12, 2010 3:14 AM
  • I don't think anything is radically different here. Gacutil has always been only in an SDK except for one brief interval where it was in the .NET FW 1.1 redist, and there's just some time before there's a relevant SDK, the Win SDK 7.1 "coming soon" http://blogs.msdn.com/windowssdk/archive/2010/04/07/coming-soon-win-sdk-for-windows-7-and-net-4.aspx  as a standalone product.

    I use an install package ;=)


    Phil Wilson
    • Marked as answer by Figo Fei Monday, May 3, 2010 2:18 AM
    • Unmarked as answer by smithery Tuesday, May 11, 2010 12:33 AM
    • Marked as answer by Figo Fei Monday, May 24, 2010 7:38 AM
    Friday, April 16, 2010 8:16 PM

All replies

  • I don't think anything is radically different here. Gacutil has always been only in an SDK except for one brief interval where it was in the .NET FW 1.1 redist, and there's just some time before there's a relevant SDK, the Win SDK 7.1 "coming soon" http://blogs.msdn.com/windowssdk/archive/2010/04/07/coming-soon-win-sdk-for-windows-7-and-net-4.aspx  as a standalone product.

    I use an install package ;=)


    Phil Wilson
    • Marked as answer by Figo Fei Monday, May 3, 2010 2:18 AM
    • Unmarked as answer by smithery Tuesday, May 11, 2010 12:33 AM
    • Marked as answer by Figo Fei Monday, May 24, 2010 7:38 AM
    Friday, April 16, 2010 8:16 PM
  • Thanks for the answer Phil. I have been reading that in various places. Previously you could use the configuration tool to do that.

    What doesn't make sense is for me to create an install package to install the third party DLL which I just installed on my machine and would like to add to the production machine but without all the development stuff that goes with it. AND, that assumes it installs it in the GAC which some of them don't do (actually the majority don't, especially if they give you the source code which allows you the option of creating a GAC ready assembly).

    Seems like an awful lot of work. Interestly, in all the time I have been doing .NET (since the beginning), I have never had to create an install package. And it doesn't make sense to have to create an install package when you have full control over your production machines and are just adding the 3rd party DLLs.

    Friday, April 16, 2010 8:51 PM
  • Hi smithery

    Previously, to install assemblies into GAC we'd got following ways:

    • Using the Global Assembly Cache tool (Gacutil.exe).
      Note: Gacutil.exe is only for development purposes and should not be used to install production assemblies into the global assembly cache. 
    • Using Microsoft Windows Installer 2.0.
      This is the recommended and most common way to add assemblies to the global assembly cache. The installer provides reference counting of assemblies in the global assembly cache, plus other benefits.
    • Using a Windows shell extension provided by the Windows Software Development Kit (SDK) called the Assembly Cache Viewer (Shfusion.dll).
      The shell extension allows you to drag assemblies into the global assembly cache.
    • Using the .NET Framework Configuration Tool (Mscorcfg.msc).
      The .NET Framework Configuration Tool (Mscorcfg.msc) allows you to view the global assembly cache and add new assemblies to the cache.

    Hope it helps.

    Thanks.


    Figo Fei
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com 


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Edited by Figo Fei Tuesday, April 27, 2010 1:36 AM
    Tuesday, April 20, 2010 3:32 AM
  • Figo,

    The .NET Framework Configuraiton Tool was my preferred method of managing assemblies on the production machine. However, for the .NET 4 assemblies, that is not possible. So, how to do get an assembly to the production machine? There is very little documentaiton on this which is truly amazing given that .NET is almost 10 years old and quite mature. There is no documentation regarding this for .NET 4. I find it difficult to believe that a painful mechanism of having to use the Microsoft Windows Installer 2.0 to simply get a third party assembly into the GAC is needed. For a task that should take 30 seconds or less, you need to spend a lot of time building the installation. This also goes against the premise that ASP.NET developers (for which I am adding the assemblies into the GAC for) of simple copy and run. I have never had to use the Windows Installer in 10 years of ASP.NET development. So, someone's fuzzy logic is way out of whack here regarding this process.

    Cheers,

    Matt.

    Tuesday, April 20, 2010 10:18 AM
  • I just ran up against this today. I installed .net 4 on my Win XP SP3 system, recompiled my library, and can't put it into the GAC.

    I have the 90-day trial of VS 2010, but I have no interest in installing a trial version of anything. I have no plans for buying VS 2010 at this time -- I just don't have the money.

    .net comes with the compilers (CSC and VBC), it should come with GACUTIL.

    Friday, April 23, 2010 3:28 AM
  • I too am boggled that I can't find any information about the changes to the GAC in .Net 4.  We have long been using a Post-Build event to add our assemblies to the GAC with a command like:

    "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\gacutil" /if "$(TargetPath)"

    For .Net 4.0, we changed our post-build to do this:

    "C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\gacutil" /if "$(TargetPath)"

    However, I don't know yet if that works.  There are several oddities:

    1) If you open c:\windows\assembly you won't see the file there, even though our post-build step indicates the file was successfully added to the GAC.

    2) If you look in the "Download" subfolder of c:\windows\assembly you will see the file.

    3) If you run GACUtil /l it will also show the file.

    4) In the Download subfolder, some assemblies are listed as "Private", and some as "Shared".  What does that mean?  Which one should we use?

    5) At the moment, we have taken the gac-util step out of our nant build because it fails.  I had ASSumed, perhaps falsely, that I would be able to call a new command to replace it.  I guess that new command will be calling the gacutil.exe.

    6) I am not sure how we will deploy this at clients.  I guess it depends on what Install Shield will do for us.  Perhaps our current installer works.

    7) Why is there not an Assembly Manager for the .Net 4.0 GAC as there is for 1.1 and 2.0?

    If anyone learns that Microsoft has documented the changes and best practices for GAC management for that answers all these questions, I'd love for you to post the link here.  All I have found is the gacutil documentation which explains the syntax for the tool, but not when to use "private" vs "shared" nor how 2.0 and 4.0 interact nor how to manage the GAC on client PCs.

    Monday, April 26, 2010 6:02 PM
  • Hi Figo, I think you should alter your response with respect to .Net 4.0:

    1) yes, gacutil still appears to function for .Net 4.0

    2) Is Windows Installer 2.0 the way to go?  I only question this because the following two items (3 and 4) do NOT work:

    3) I don't see my .Net 4 assemblies through Windows Explorer (Shfusiion.dll) (is this a bug?).  Gacutil lists them, but they do not appear in c:\windows\assembly.  The do appear to be in c:\windows\assembly\Download - but I don't understand the purpose of the Download subfolder yet, or why I have so many instances of my assembly, or why some instances are private and some are shared.

    4) Per http://msdn.microsoft.com/en-us/library/2bc0cxhc.aspx, mscorcfg.msc is obsolete.

    Monday, April 26, 2010 6:21 PM
  • Hi

    Thanks for your response.

    The CLR version of .NET Framework 2.0/3.5 (CLR 2.0) is different from the one of .NET 4.

    GACUtil tool ships with .NET Framework SDK. In .NET Framework 4.0, the GAC was split into two, one for each CLR(to avoid breaking old applications).

    The main change is that CLR v2.0 applications now cannot see CLR v4.0 assemblies in the GAC.

    As Phil Wilson mentioned, the new tool with SDK for .NET 4 is coming soon: http://blogs.msdn.com/windowssdk/archive/2010/04/07/coming-soon-win-sdk-for-windows-7-and-net-4.aspx 

    By the way, in deployment scenarios, use Windows Installer 2.0 to install assemblies into the global assembly cache. Use Windows Explorer or the Global Assembly Cache tool only in development scenarios, because they do not provide assembly reference counting and other features provided when using the Windows Installer.

    The document of deployment of .NET 4 is avail as follows:

    Microsoft .NET Framework 4 deployment guide for administrators http://msdn.microsoft.com/library/ee390831(v=VS.100).aspx

    Microsoft .NET Framework 4 deployment guide for developers http://msdn.microsoft.com/library/ee942965(v=VS.100).aspx

    Hope it help.

    Thanks.


    Figo Fei
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com 


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Figo Fei Monday, May 3, 2010 2:18 AM
    • Unmarked as answer by smithery Tuesday, May 11, 2010 12:33 AM
    Tuesday, April 27, 2010 1:35 AM
  • Figo,

    We all really don't understand why this has been made so hard. I have third party DLL assemblies (23 to be exact) where I now will need to create and maintain separate install packages if I am using your deployment scenario correctly. Collectively, that will waste millions of hours of developers time when a tool similar to what we had allows us to easily and correctly add a DLL asembly to the GAC.

    What is the real reason why this is being done this way? The reasons you provide here don't rasie any red flags as to why a GUI tool could not understand that the DLL assembly belongs in one GAC or the other especially if the gacutil can do it.

    I suspect that most people will build simple command line tools around the gacutil because that will be the fastest and easiest way to get the job done. We all don't have the time to build install packages for the third party DLL assemblies.

    Right now, I would gladly pay for a third party tool which is similar to the configuration tool.

     

    Cheers,

    Matt.

    Tuesday, April 27, 2010 10:06 AM
  • Hi Matt,

    For applications targets on old versions, you can still use the old gacutil to install assemblies into "old" GAC. For .NET 4 application, the new gacutil is about to ships with the new SDK.

    As for the reason, I think it is to avoid breaking the old applications, they have no idea how the future versions of .NET works, even for all software, it's hard or impossible to do the forward compatibility well.

    Thanks.


    Figo Fei
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com 


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Wednesday, April 28, 2010 1:43 AM
  • Figo,

    After much struggling, I am still very baffled how to add my third party assemblies to the GAC for .NET 4. It seems that you simply cannot copy the gactuil.exe to the folder. If you do and try to get command line help, nothing appears except the copyright.

    Also, given that the new help is a 1.0 product which by all rights means it is useless (and believe me it is useless), I am trying to find documentation on how to create a windows installer package to add these third party assemblies to the GAC. I really do not want to go back to including 70MB of third party assemblies to my bin folder and have to copy over 75 MB worth of stuff to production servers through slow internet connections. This can be very painful and a huge waste of time.

    Thanks,

    Matt.

    Tuesday, May 11, 2010 12:39 AM
  • Hi Matt

    Besides the new version of Windows SDK as a standalone product, if you installed VS2010, you can find a new version of gacutil.exe at %ProgramFiles%\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\.

    I've tried and it works nicely.

    Thanks.


    Figo Fei
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com 


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Tuesday, May 11, 2010 3:47 AM
  • Figo,

    Did you copy the gacutil.exe from the original folder to another machine or even the same machine but a different drive? Yes, it does work nicely within the folder it was installed into. But, it does not work if you copy it elsewhere.

    I have also not seen the SDK as a standalone product and I would like to start testing my .NET 4 versions on QA machines to roll out onto production machines as soon as I can.

    Matt.

    Tuesday, May 11, 2010 9:53 AM
  • Hi Matt

    We must copy the gacutlrc.dll (in subfolder 1033) with the gacutil.exe as its extension.

    Thanks.


    Figo Fei
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com 


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Figo Fei Monday, May 24, 2010 7:38 AM
    Wednesday, May 12, 2010 3:14 AM
  • Hi Matt

    Have you solved this problem?

    Thanks.


    Figo Fei
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com 


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Tuesday, May 18, 2010 5:48 AM
  • Matt, I marked this thread, but feel free to unmark it, if the problem isn't solved and you have more info to provide for further investigation.

    Thanks.


    Figo Fei
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com 


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Monday, May 24, 2010 7:38 AM
  • To clarify Figo's answer, the following is the solution that worked perfectly for me. I have VS2010, but I guess if you installed the Windows SDK for Windows 7 and .NET Framework 4 you'd have gacutil in the same location too.

    I copied the following files from  C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools   

    to a folder on the server containing the DLLs I wanted to install:

    • gacutil.exe
    • gacutil.exe.config
    • 1033\gacutlrc.dll     (can be placed in the same dir as gacutil.exe on the server)

    Then I ran:    gacutil.exe -I <dllfilename>     to install the DLLs in the GAC.

    Note: if you don't include gacutlrc.dll in the same directory as gacutil.exe on the server, when you run gacutil.exe it doesn't actually 'do' anything - just exits without error.

    Hope that helps.

     

    • Marked as answer by Figo Fei Tuesday, June 1, 2010 5:53 AM
    Friday, May 28, 2010 4:24 PM
  • Hi Markdecates,

    Thank you very much. It's really very helpful.

    Thanks again!!!!

    Saturday, March 5, 2016 5:31 AM