title: NHibernate unable to load assemblies (NHibernate.ByteCode.Castle and BusinessLogic) from GAC
body: <p>I was lookin all over the internet for this particular problem of mine. I found some suggested solutions but they don't work.</p>
  
  <p>Here is the setup:</p>
  
  <p>I am using ActiveRecord/NHibernate. I created an assembly wrapping ActiveRecord called the BusinessLogic. The idea is that all my projects should use the BusinessLogic instead of referencing ActiveRecord/NHibernate directly.</p>
  
  <p>I installed the following files in the GAC (Global Assembly Cache of .NET):</p>
  
  <ul>
  <li>Antlr3.Runtime.dll BusinessLogic.dll</li>
  <li>BusinessLogic.dll</li>
  <li>Castle.ActiveRecord.dll</li>
  <li>Castle.Components.Validator.dll</li>
  <li>Castle.Core.dll</li>
  <li>Castle.DynamicProxy2.dll</li>
  <li>Iesi.Collections.dll log4net.dll</li>
  <li>NHibernate.ByteCode.Castle.dll</li>
  <li>NHibernate.dll</li>
  </ul>
  
  <p>The Problem is the following: When I execute my ASP.NET application that reads product information from the database I get the following error message:</p>
  
  <pre><code>Unable to load type 'NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle' during configuration of proxy factory class.
  Possible causes are:
  - The NHibernate.Bytecode provider assembly was not deployed.
  - The typeName used to initialize the 'proxyfactory.factory_class' property of the session-factory section is not well formed.
  </code></pre>
  
  <p>If I put a local copy of NHibernate.ByteCode.Castle.dll into the bin folder of the ASP.NET application the error is gone. But a new error shows up. It says that NHibernate cannot find the classes within the BusinessLogic.dll (e.g. Product and so on).</p>
  
  <p>If I put a local copy of BusinessLogic.dll into the bin folder of the ASP.NET application even this error is fixed and the application runs great.</p>
  
  <p>This however is not desired, because I don't want to recompile every application using the BusinessLogic, whenever the BusinessLogic is updated.</p>
  
  <p>I found this article that promised to be helpful: <a href="http://markmail.org/message/o22r2x5fng7i6jn5#query:activerecord%20gac+page:1+mid:4rlqoicqyxjh3ypb+state:results" rel="nofollow noreferrer">http://markmail.org/message/o22r2x5fng7i6jn5#query:activerecord%20gac+page:1+mid:4rlqoicqyxjh3ypb+state:results</a></p>
  
  <p>Unfortunately this does not solve the problem.</p>
  
  <p>I put the following into the machine.config file:</p>
  
  <pre><code>&lt;runtime&gt;
    &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
      &lt;qualifyAssembly partialName="NHibernate.ByteCode.Castle" fullName="NHibernate.ByteCode.Castle,version=2.1.2.4000,publicKeyToken=aa95f207798dfdb4,culture=neutral" /&gt;
    &lt;/assemblyBinding&gt;
  &lt;/runtime&gt;
  </code></pre>
  
  <p>The error is still the same. NHibernate cannot find the class NHibernate.ByteCode.Castle.ProxyFactoryFactory</p>
  
  <p>Any help is much appreciated.</p>