title: C# - Registering dependency dlls necessary for COM Visible Class?
body: <p>I have a C# library that was developed in-house to provide an interface to our legacy software. Over the time requirements grew and now here I am to add COM visibility to this interface library so that it can be accessed from something like VBA in the MS Office applications. </p>
  
  <p>Update 3: Added bit more details in the 'Existing Design' text.</p>
  
  <p><strong>Existing Design:</strong>
  Let's call my interface library as <em>Interface.dll</em>. It's a facade pattern which includes some backend /dlls, which are dependencies for this <em>Interface.dll</em>. Let's call them as:
  <em>MyTypeLib.dll, MyHelper1.dll, MyHelper2.dll</em> and few more helpers. Every .dll mentioned above is a separate library project in my solution.</p>
  
  <p><strong>My approach was:</strong><br>
  Develop a new library that has a COM visible class. I did something like:</p>
  
  <p>Update 1,2: Added my interface sample code</p>
  
  <pre><code>[Guid("CE3750B7-DE31-4635-A69C-110B1271B363")]
  public interface ICOMVisibleClass
  {
     ...
     ...
  }
  
  [ComVisible(true)]
  [ClassInterface(ClassInterfaceType.AutoDual)]
  [Guid("A023101A-D9B3-4A24-AAE4-B3CFEDA04BAF")]
  public class MyCOMVisibleClass : ICOMVisibleClass
  {
     ...
     ...
  }
  </code></pre>
  
  <p>and selectively call methods from <em>Interface.dll</em>, making these selected methods COM visible. Let's say above class produces <em>MyCOMVisibleClassLib.dll</em>. I used RegAsm.exe to register this library and to produce <em>MyCOMVisibleClassLib.tlb</em> file.</p>
  
  <p>To test this implementation, I decided to use MS Excel 2010. I opened VBA editor and added a reference to <em>MyCOMVisibleClassLib.tlb</em>. In the code, I can now see all the methods in  MyCOMVisibleClass so it seems to be working until..... </p>
  
  <p>I ran this code and got "Run-time Error -2146233088 (80131500). Unable to find MyTypeLib.dll"
  I used Assembly Binding Log Viewer to see more details of this error and found that MS Excel was looking for this (MyTypeLib.dll) everywhere except where actually this file is. If I copy this file into Excel installation folder under Program Files, Excel would compain about next dependency - MyHelper1.dll and so on. After I copied all the dlls to Excel install folder all was good. But this is not the solution I am looking for.</p>
  
  <p><strong>Questions:</strong></p>
  
  <ol>
  <li>Is my approach correct to open up few methods to COM?</li>
  <li>I think that <em>MyCOMVisibleClassLib.dll</em> is the only one that needs to be registered. Am I right in thinking so?</li>
  <li>How do I make Excel to find all my dependencies (<em>MyTypeLib.dll, MyHelper1.dll, MyHelper2.dll</em> ) without having to copy them in MS Excel install folder?</li>
  </ol>
  
  <p>I also think that I am missing something basic that I should have known before I start this but can't seem to figure it out.</p>
  
  <p>Any help is very much appreciated. Thanks in advance.</p>