title: Additional information: No se puede cargar el archivo o ensamblado 'BtLib.dll' ni una de sus dependencias
body: <p>I have the following code.</p>
  
  <pre><code> public CuentasCobrarBL(string rutaDatos)
          {
              rutaDirec = new CompanyBL(rutaDatos).rutaDirectorio;
              CompanyBL companybl = new CompanyBL(rutaDatos);
              Compania compania =  companybl.CargarCompania();
  }
  
  
  
  
  public ilimitada.Dominio.Pervasive.SCI.Core.Entidades.Compania CargarCompania()
          {
              ilimitada.Dominio.Pervasive.SCI.Core.Entidades.Compania companium = null;
              using (IPervasive&lt;ilimitada.Dominio.Pervasive.SCI.Core.DAO.Estructuras.Compania&gt; pervasive = BtrieveDataProvider&lt;ilimitada.Dominio.Pervasive.SCI.Core.DAO.Estructuras.Compania&gt;.Create(this.rutaDirectorio, 999))
              {
                  //    pervasive.DataBuffer = new ilimitada.Dominio.Pervasive.SCI.Core.DAO.Estructuras.Compania();
                  //    int num = (ushort)Marshal.SizeOf&lt;ilimitada.Dominio.Pervasive.SCI.Core.DAO.Estructuras.Compania&gt;(new ilimitada.Dominio.Pervasive.SCI.Core.DAO.Estructuras.Compania());
                  //    if (pervasive.Open(OpenMode.Normal))
                  //    {
                  //        if (pervasive.GetFirst())
                  //        {
                  //            companium = CompaniaCV.ConvertirEstructuraEnObjeto(pervasive.DataBuffer);
                  //        }
                  //    }
              }
              return companium;
          }
  </code></pre>
  
  <p>The using line is throwing me this exception.</p>
  
  <blockquote>
    <p>Additional information: No se puede cargar el archivo o ensamblado
    'BtLib.dll' ni una de sus dependencias. No se puede encontrar el
    módulo especificado.</p>
  </blockquote>
  
  <p>The BRetrieverDataProvider file is this:</p>
  
  <pre><code>using BtLib;
  using Microsoft.Practices.Unity;
  using Microsoft.Practices.Unity.InterceptionExtension;
  using System;
  using System.Runtime.CompilerServices;
  using System.Runtime.InteropServices;
  using System.Text;
  
  namespace ilimitada.AccesoDatos.Pervasive.Btrieve
  {
      public class BtrieveDataProvider&lt;T&gt; : IPervasive&lt;T&gt;, IDisposable
      where T : class
      {
          private static IUnityContainer container;
  
          private short keyBufLen;
  
          private ushort structSize;
  
          private IntPtr pointer;
  
          private byte[] positionBlock;
  
          private byte[] keyBuffer;
  
          private string bufferName;
  
          private bool isDisposed;
  
          private LockBias lockbias;
  
          public T DataBuffer
          {
              get;
              set;
          }
  
          public short KeyNumber
          {
              get;
              set;
          }
  
          public short Status
          {
              get;
              set;
          }
  
          public BtrieveDataProvider(string fullFilePath, ushort structSize)
          {
              this.bufferName = fullFilePath;
              this.keyBuffer = Encoding.ASCII.GetBytes(this.bufferName);
              this.keyBuffer = new byte[255];
              byte[] bytes = Encoding.ASCII.GetBytes(this.bufferName);
              Array.Copy(bytes, this.keyBuffer, (int)bytes.Length);
              this.positionBlock = new byte[128];
              this.keyBufLen = 128;
              this.structSize = structSize;
              this.pointer = IntPtr.Zero;
              this.KeyNumber = 0;
              this.Status = -1;
              this.lockbias = LockBias.NoLock;
          }
  
          public void AbortTransaction()
          {
              byte[] numArray = new byte[128];
              byte[] bytes = Encoding.ASCII.GetBytes(this.bufferName);
              this.pointer = Marshal.AllocCoTaskMem((int)this.structSize);
              Marshal.StructureToPtr&lt;T&gt;(this.DataBuffer, this.pointer, true);
              this.Status = Native.BtrCall(Operation.AbortTrans, numArray, this.pointer, ref this.structSize, bytes, this.keyBufLen, this.KeyNumber);
              Marshal.FreeCoTaskMem(this.pointer);
              if (this.Status != 0)
              {
                  throw new BtrieveException(this.Status);
              }
          }
  
          public void BeginTransaction(bool concurrent)
          {
              byte[] numArray = new byte[128];
              byte[] bytes = Encoding.ASCII.GetBytes(this.bufferName);
              this.pointer = Marshal.AllocCoTaskMem((int)this.structSize);
              Marshal.StructureToPtr&lt;T&gt;(this.DataBuffer, this.pointer, true);
              if (!concurrent)
              {
                  this.Status = Native.BtrCall(Operation.BeginTrans, numArray, this.pointer, ref this.structSize, bytes, this.keyBufLen, this.KeyNumber);
              }
              else
              {
                  this.Status = Native.BtrCall(Operation.BeginConCurrentTransaction, numArray, this.pointer, ref this.structSize, bytes, this.keyBufLen, this.KeyNumber);
              }
              Marshal.FreeCoTaskMem(this.pointer);
              if (this.Status != 0)
              {
                  throw new BtrieveException(this.Status);
              }
          }
  
          public void Close()
          {
              this.keyBuffer = Encoding.ASCII.GetBytes(this.bufferName);
              this.pointer = Marshal.AllocCoTaskMem((int)this.structSize);
              Marshal.StructureToPtr&lt;T&gt;(this.DataBuffer, this.pointer, true);
              this.Status = Native.BtrCall(Operation.Close, this.positionBlock, this.pointer, ref this.structSize, this.keyBuffer, this.keyBufLen, this.KeyNumber);
              Marshal.FreeCoTaskMem(this.pointer);
              if (this.Status != 0)
              {
                  throw new BtrieveException(this.Status);
              }
          }
  
          public static IPervasive&lt;T&gt; Create(string fullFilePath, ushort structSize)
          {
              BtrieveDataProvider&lt;T&gt;.container = new UnityContainer();
              BtrieveDataProvider&lt;T&gt;.container.AddNewExtension&lt;Interception&gt;();
              IUnityContainer unityContainer = BtrieveDataProvider&lt;T&gt;.container;
              InjectionMember[] interceptor = new InjectionMember[] { new Interceptor&lt;InterfaceInterceptor&gt;(), new InterceptionBehavior&lt;LoggingInterceptionBehavior&gt;(), null };
              object[] objArray = new object[] { fullFilePath, structSize };
              interceptor[2] = new InjectionConstructor(objArray);
              unityContainer.RegisterType&lt;IPervasive&lt;T&gt;, BtrieveDataProvider&lt;T&gt;&gt;(interceptor);
              return BtrieveDataProvider&lt;T&gt;.container.Resolve&lt;IPervasive&lt;T&gt;&gt;(new ResolverOverride[0]);
          }
  
          public bool Create(IntPtr pointerStructure, ushort size)
          {
              this.Status = Native.BtrCall(Operation.Create, this.positionBlock, pointerStructure, ref size, this.keyBuffer, this.keyBufLen, this.KeyNumber);
              if (this.Status != 0)
              {
                  throw new BtrieveException(this.Status);
              }
              return this.Status == 0;
          }
  
          public bool Delete()
          {
              this.pointer = Marshal.AllocCoTaskMem((int)this.structSize);
              Marshal.StructureToPtr&lt;T&gt;(this.DataBuffer, this.pointer, true);
              this.Status = Native.BtrCall(Operation.Delete, this.positionBlock, this.pointer, ref this.structSize, this.keyBuffer, this.keyBufLen, this.KeyNumber);
              Marshal.PtrToStructure&lt;T&gt;(this.pointer, this.DataBuffer);
              Marshal.FreeCoTaskMem(this.pointer);
              if (this.Status != 0 &amp;&amp; this.Status != 8)
              {
                  throw new BtrieveException(this.Status);
              }
              return this.Status == 0;
          }
  
          public void Dispose()
          {
              if (!this.isDisposed)
              {
                  try
                  {
                      if (BtrieveDataProvider&lt;T&gt;.container != null)
                      {
                          BtrieveDataProvider&lt;T&gt;.container.Dispose();
                      }
                      this.isDisposed = true;
                      this.Close();
                  }
                  catch (System.Exception exception)
                  {
                  }
              }
          }
  
          public void EndTransaction()
          {
              byte[] numArray = new byte[128];
              byte[] bytes = Encoding.ASCII.GetBytes(this.bufferName);
              this.pointer = Marshal.AllocCoTaskMem((int)this.structSize);
              Marshal.StructureToPtr&lt;T&gt;(this.DataBuffer, this.pointer, true);
              this.Status = Native.BtrCall(Operation.EndTrans, numArray, this.pointer, ref this.structSize, bytes, this.keyBufLen, this.KeyNumber);
              Marshal.FreeCoTaskMem(this.pointer);
              if (this.Status != 0)
              {
                  throw new BtrieveException(this.Status);
              }
          }
  
          public void FinishtLockRecord()
          {
              this.lockbias = LockBias.NoLock;
          }
  
          public void GetDirect()
          {
              this.pointer = Marshal.AllocCoTaskMem((int)this.structSize);
              Marshal.StructureToPtr&lt;T&gt;(this.DataBuffer, this.pointer, true);
              this.Status = Native.BtrCall(Operation.GetDirect, this.positionBlock, this.pointer, ref this.structSize, this.keyBuffer, this.keyBufLen, this.KeyNumber);
              Marshal.PtrToStructure&lt;T&gt;(this.pointer, this.DataBuffer);
              Marshal.FreeCoTaskMem(this.pointer);
              if (this.Status != 0)
              {
                  throw new BtrieveException(this.Status);
              }
          }
  
          public bool GetEqual(string condition)
          {
              this.keyBuffer = Encoding.Default.GetBytes(condition);
              this.pointer = Marshal.AllocCoTaskMem((int)this.structSize);
              Marshal.StructureToPtr&lt;T&gt;(this.DataBuffer, this.pointer, true);
              this.Status = Native.BtrCall(Native.AddLockBias(Operation.GetEqual, this.lockbias), this.positionBlock, this.pointer, ref this.structSize, this.keyBuffer, this.keyBufLen, this.KeyNumber);
              Marshal.FreeCoTaskMem(this.pointer);
              if (this.Status != 0 &amp;&amp; this.Status != 4)
              {
                  throw new BtrieveException(this.Status);
              }
              return this.Status == 0;
          }
  
          public bool GetFirst()
          {
              this.pointer = Marshal.AllocCoTaskMem((int)this.structSize);
              Marshal.StructureToPtr&lt;T&gt;(this.DataBuffer, this.pointer, true);
              this.Status = Native.BtrCall(Native.AddLockBias(Operation.GetFirst, this.lockbias), this.positionBlock, this.pointer, ref this.structSize, this.keyBuffer, this.keyBufLen, this.KeyNumber);
              Marshal.PtrToStructure&lt;T&gt;(this.pointer, this.DataBuffer);
              Marshal.FreeCoTaskMem(this.pointer);
              if (this.Status != 0 &amp;&amp; this.Status != 9)
              {
                  throw new BtrieveException(this.Status);
              }
              return this.Status == 0;
          }
  
          public bool GetGreater(string condition)
          {
              this.keyBuffer = Encoding.Default.GetBytes(condition);
              this.pointer = Marshal.AllocCoTaskMem((int)this.structSize);
              Marshal.StructureToPtr&lt;T&gt;(this.DataBuffer, this.pointer, true);
              this.Status = Native.BtrCall(Native.AddLockBias(Operation.GetGreater, this.lockbias), this.positionBlock, this.pointer, ref this.structSize, this.keyBuffer, this.keyBufLen, this.KeyNumber);
              Marshal.FreeCoTaskMem(this.pointer);
              if (this.Status != 0 &amp;&amp; this.Status != 9)
              {
                  throw new BtrieveException(this.Status);
              }
              return this.Status == 0;
          }
  
          public bool GetGreaterOrEqual(string condition)
          {
              this.keyBuffer = Encoding.Default.GetBytes(condition);
              this.pointer = Marshal.AllocCoTaskMem((int)this.structSize);
              Marshal.StructureToPtr&lt;T&gt;(this.DataBuffer, this.pointer, true);
              this.Status = Native.BtrCall(Native.AddLockBias(Operation.GetGreaterOrEqual, this.lockbias), this.positionBlock, this.pointer, ref this.structSize, this.keyBuffer, this.keyBufLen, this.KeyNumber);
              Marshal.PtrToStructure&lt;T&gt;(this.pointer, this.DataBuffer);
              Marshal.FreeCoTaskMem(this.pointer);
              if (this.Status != 0 &amp;&amp; this.Status != 9)
              {
                  throw new BtrieveException(this.Status);
              }
              return this.Status == 0;
          }
  
          public bool GetLast()
          {
              this.pointer = Marshal.AllocCoTaskMem((int)this.structSize);
              Marshal.StructureToPtr&lt;T&gt;(this.DataBuffer, this.pointer, true);
              this.Status = Native.BtrCall(Native.AddLockBias(Operation.GetLast, this.lockbias), this.positionBlock, this.pointer, ref this.structSize, this.keyBuffer, this.keyBufLen, this.KeyNumber);
              Marshal.PtrToStructure&lt;T&gt;(this.pointer, this.DataBuffer);
              Marshal.FreeCoTaskMem(this.pointer);
              if (this.Status != 0 &amp;&amp; this.Status != 9)
              {
                  throw new BtrieveException(this.Status);
              }
              return this.Status == 0;
          }
  
          public bool GetLessThan(string condition)
          {
              this.keyBuffer = Encoding.Default.GetBytes(condition);
              this.pointer = Marshal.AllocCoTaskMem((int)this.structSize);
              Marshal.StructureToPtr&lt;T&gt;(this.DataBuffer, this.pointer, true);
              this.Status = Native.BtrCall(Native.AddLockBias(Operation.GetLessThan, this.lockbias), this.positionBlock, this.pointer, ref this.structSize, this.keyBuffer, this.keyBufLen, this.KeyNumber);
              Marshal.PtrToStructure&lt;T&gt;(this.pointer, this.DataBuffer);
              Marshal.FreeCoTaskMem(this.pointer);
              if (this.Status != 0 &amp;&amp; this.Status != 9)
              {
                  throw new BtrieveException(this.Status);
              }
              return this.Status == 0;
          }
  
          public bool GetLessThanOrEqual(string condition)
          {
              this.keyBuffer = Encoding.Default.GetBytes(condition);
              this.pointer = Marshal.AllocCoTaskMem((int)this.structSize);
              Marshal.StructureToPtr&lt;T&gt;(this.DataBuffer, this.pointer, true);
              this.Status = Native.BtrCall(Native.AddLockBias(Operation.GetLessThanOrEqual, this.lockbias), this.positionBlock, this.pointer, ref this.structSize, this.keyBuffer, this.keyBufLen, this.KeyNumber);
              Marshal.PtrToStructure&lt;T&gt;(this.pointer, this.DataBuffer);
              Marshal.FreeCoTaskMem(this.pointer);
              if (this.Status != 0 &amp;&amp; this.Status != 9)
              {
                  throw new BtrieveException(this.Status);
              }
              return this.Status == 0;
          }
  
          public bool GetNext()
          {
              this.pointer = Marshal.AllocCoTaskMem((int)this.structSize);
              Marshal.StructureToPtr&lt;T&gt;(this.DataBuffer, this.pointer, true);
              this.Status = Native.BtrCall(Native.AddLockBias(Operation.GetNext, this.lockbias), this.positionBlock, this.pointer, ref this.structSize, this.keyBuffer, this.keyBufLen, this.KeyNumber);
              Marshal.PtrToStructure&lt;T&gt;(this.pointer, this.DataBuffer);
              Marshal.FreeCoTaskMem(this.pointer);
              if (this.Status != 0 &amp;&amp; this.Status != 8 &amp;&amp; this.Status != 9)
              {
                  throw new BtrieveException(this.Status);
              }
              return this.Status == 0;
          }
  
          public void GetPosition()
          {
              ushort num = 4;
              this.pointer = Marshal.AllocCoTaskMem((int)this.structSize);
              Marshal.StructureToPtr&lt;T&gt;(this.DataBuffer, this.pointer, true);
              this.Status = Native.BtrCall(Operation.GetPosition, this.positionBlock, this.pointer, ref num, this.keyBuffer, this.keyBufLen, this.KeyNumber);
              Marshal.PtrToStructure&lt;T&gt;(this.pointer, this.DataBuffer);
              Marshal.FreeCoTaskMem(this.pointer);
              if (this.Status != 0 &amp;&amp; this.Status != 8)
              {
                  throw new BtrieveException(this.Status);
              }
          }
  
          public bool GetPrevious()
          {
              this.pointer = Marshal.AllocCoTaskMem((int)this.structSize);
              Marshal.StructureToPtr&lt;T&gt;(this.DataBuffer, this.pointer, true);
              this.Status = Native.BtrCall(Native.AddLockBias(Operation.GetPrevious, this.lockbias), this.positionBlock, this.pointer, ref this.structSize, this.keyBuffer, this.keyBufLen, this.KeyNumber);
              Marshal.PtrToStructure&lt;T&gt;(this.pointer, this.DataBuffer);
              Marshal.FreeCoTaskMem(this.pointer);
              if (this.Status != 0 &amp;&amp; this.Status != 8 &amp;&amp; this.Status != 9 &amp;&amp; this.Status != 60 &amp;&amp; this.Status != 62 &amp;&amp; this.Status != 64)
              {
                  throw new BtrieveException(this.Status);
              }
              return this.Status == 0;
          }
  
          public int GetStat(BtrieveStatistic typeStatistic)
          {
              short num = 0;
              int nroReg = 0;
              byte[] numArray = new byte[128];
              TypeCreate typeCreate = new TypeCreate();
              ushort num1 = (ushort)Marshal.SizeOf&lt;TypeCreate&gt;(typeCreate);
              IntPtr intPtr = Marshal.AllocCoTaskMem((int)num1);
              Marshal.StructureToPtr&lt;TypeCreate&gt;(typeCreate, intPtr, true);
              num = Native.BtrCall(Operation.Stat, this.positionBlock, intPtr, ref num1, numArray, this.keyBufLen, this.KeyNumber);
              if (num == 0)
              {
                  Marshal.PtrToStructure&lt;TypeCreate&gt;(intPtr, typeCreate);
                  switch (typeStatistic)
                  {
                      case BtrieveStatistic.RecordNumber:
                      {
                          nroReg = typeCreate.NroReg;
                          break;
                      }
                      case BtrieveStatistic.KeyNumber:
                      {
                          nroReg = typeCreate.IndexCount;
                          break;
                      }
                      case BtrieveStatistic.RecordLength:
                      {
                          nroReg = typeCreate.RecLength;
                          break;
                      }
                      case BtrieveStatistic.SegmentNumber:
                      {
                          nroReg = (int)typeCreate.Keys.Length;
                          break;
                      }
                  }
              }
              Marshal.FreeCoTaskMem(intPtr);
              if (num != 0)
              {
                  throw new BtrieveException(num);
              }
              return nroReg;
          }
  
          public bool Insert()
          {
              this.pointer = Marshal.AllocCoTaskMem((int)this.structSize);
              Marshal.StructureToPtr&lt;T&gt;(this.DataBuffer, this.pointer, true);
              this.Status = Native.BtrCall(Operation.Insert, this.positionBlock, this.pointer, ref this.structSize, this.keyBuffer, this.keyBufLen, this.KeyNumber);
              Marshal.FreeCoTaskMem(this.pointer);
              if (this.Status != 0)
              {
                  throw new BtrieveException(this.Status);
              }
              return this.Status == 0;
          }
  
          public bool Open(OpenMode openMode = 0)
          {
              this.pointer = Marshal.AllocCoTaskMem((int)this.structSize);
              Marshal.StructureToPtr&lt;T&gt;(this.DataBuffer, this.pointer, true);
              int num = 0;
              do
              {
                  this.Status = Native.BtrCall(Operation.Open, this.positionBlock, this.pointer, ref this.structSize, this.keyBuffer, this.keyBufLen, (short)openMode);
                  num++;
              }
              while (num &lt;= 3 &amp;&amp; this.Status == 3012);
              Marshal.FreeCoTaskMem(this.pointer);
              if (this.Status != 0 &amp;&amp; this.Status != 12)
              {
                  throw new BtrieveException(this.Status);
              }
              return this.Status == 0;
          }
  
          public void StartLockMultiRecord()
          {
              this.lockbias = LockBias.MultiNoWait;
          }
  
          public void StartLockRecord()
          {
              this.lockbias = LockBias.SingleNoWait;
          }
  
          public bool Update()
          {
              this.pointer = Marshal.AllocCoTaskMem((int)this.structSize);
              Marshal.StructureToPtr&lt;T&gt;(this.DataBuffer, this.pointer, true);
              this.Status = Native.BtrCall(Operation.Update, this.positionBlock, this.pointer, ref this.structSize, this.keyBuffer, this.keyBufLen, this.KeyNumber);
              Marshal.PtrToStructure&lt;T&gt;(this.pointer, this.DataBuffer);
              Marshal.FreeCoTaskMem(this.pointer);
              if (this.Status != 0 &amp;&amp; this.Status != 8)
              {
                  throw new BtrieveException(this.Status);
              }
              return this.Status == 0;
          }
      }
  }
  </code></pre>
  
  <p>If I compile the solution is compiled without problems, the dll is put on the bin folder, but it looks like it cant be found by the program.</p>
  
  <p>Help please.</p>