title: System.EnterpriseServices.Internal.Publish.GacInstall not working but no errors
body: <p>Here is my code:</p>
  
  <pre><code>var s = new System.EnterpriseServices.Internal.Publish();
  foreach (string file in Directory.EnumerateFiles(@"C:\Program Files\MyFolder\MSPractices"))
  {
      Console.WriteLine("GACing " + file);
      s.GacInstall(file);
  }
  </code></pre>
  
  <p>These are the files I'm trying to GAC (version 6.0.1304.0)</p>
  
  <blockquote>
    <p>Microsoft.Practices.EnterpriseLibrary.Caching.dll
    Microsoft.Practices.EnterpriseLibrary.Common.dll
    Microsoft.Practices.EnterpriseLibrary.Data.dll
    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll
    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll
    Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll
    Microsoft.Practices.EnterpriseLibrary.Logging.dll
    Microsoft.Practices.EnterpriseLibrary.PolicyInjection.dll
    Microsoft.Practices.EnterpriseLibrary.Security.dll
    Microsoft.Practices.EnterpriseLibrary.Validation.dll
    Microsoft.Practices.ServiceLocation.dll
    Microsoft.Practices.Unity.Configuration.dll
    Microsoft.Practices.Unity.dll
    Microsoft.Practices.Unity.Interception.Configuration.dll
    Microsoft.Practices.Unity.Interception.dll</p>
  </blockquote>
  
  <p>They were given to me by someone else so I'm not sure where you can get them but surely they're available online.</p>
  
  <p>The code correctly outputs that list and does not throw any exceptions but running <code>gacutil /l</code> reveals that only a few of them (highlighted below) are actually installed.</p>
  
  <p><a href="https://i.stack.imgur.com/lmcMi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lmcMi.png" alt="enter image description here"></a></p>
  
  <p>What can be going wrong?</p>
  
  <p>POSSIBLY IMPORTANT: My real issue is that this doesn't work in my InstallShield InstallScript installer with similar code (using the EnterpriseServices.Internal.Publish object).</p>
  
  <p><a href="https://msdn.microsoft.com/en-us/library/system.enterpriseservices.internal.publish.gacinstall(v=vs.100).aspx" rel="nofollow noreferrer">UPDATE</a>:</p>
  
  <blockquote>
    <p>This method throws no exception!  ...for anything!
    <code>Publish pub = new Publish(); pub.GacInstall("foo");</code></p>
    
    <p>No error, no exception.  If the path is valid, and the assembly is
    strongly named, it will get properly installed in the GAC.  Works for
    target .NET Frame version of assembly.  I.e. a .NET Framework 4.0 app
    using GacInstall will properly install a 3.5 targeted assembly, etc.</p>
    
    <p>Update (2011/12/13) - After using ILSpy to look at the code for this
    function, I did discover that errors are sent to the local machine's
    Event Viewer:</p>
  </blockquote>
  
  <p>Unfortunately, all events in the event viewer say only </p>
  
  <blockquote>
    <p>Installation in the global assembly cache failed: foo</p>
  </blockquote>