title: Problems referencing com dlls in vs 2010
body: <p>I'm running a 32 bit ver of win7 in a vm. I am trying to reference 5 com dlls (VB6) in my .net project. These dlls (and their dependencies) are registered ok since I can use them natively as they form a part of another app and that app is working fine. </p>
  
  <p>I try to set a reference to any of them directly in vs and I get the error message - Library not registered (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).</p>
  
  <p>However, if I set a reference to another com component (which I don't want to reference but which in turn does reference these libs) I find that the references to these com dlls (which I do want to reference) gets set correctly in vs. I then just need to remove the ref to the unwanted dll and everything seems to be good to go.</p>
  
  <p>If I look at the GUID and version details of one of the successfully referenced component, they appear to be the same as the GUID and version that appears in the caption of the error form, when I unsuccessfully try and set a reference to the same component directly.</p>
  
  <p>BTW I have tried repairing the VS installation to no avail</p>
  
  <p>I was wondering if someone could explain what I am doing wrong.</p>
  
  <p>EDIT: Follow-up following Hans suggestion</p>
  
  <p>So I ran </p>
  
  <pre><code>tlbimp mylib.dll
  </code></pre>
  
  <p>and it returned a TI1006 error - Output would overwrite the input file. So following suggestions found, I then issued</p>
  
  <pre><code>tlbimp mylib.dll /OUT:interop.mylib.dll
  </code></pre>
  
  <p>and this then returned the error </p>
  
  <p>TlbImp : warning TI3011 : Type library importer has encountered an interface not derived from IUnknown: '_HiddenInterface'. The interface is skipped.
  TlbImp : error TI1033 : Cannot find type 'ADODB._Recordset_Deprecated' in 'ADODB, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. There could be a mismatch between the referenced assembly and the type library.</p>
  
  <p>But I'm not sure if this is a red herring since this lib could be referenced when successfully referencing the different higher level dll. I have tried with a dll which doesn't reference ADODB and that seems to work using tlbimp. So, e.g.</p>
  
  <pre><code>tlbimp myNONADODBlib.dll /OUT:interop.myNONADODBlib.dll
  </code></pre>
  
  <p>works from the commandline. However </p>
  
  <pre><code>tlbimp myNONADODBlib.dll
  </code></pre>
  
  <p>still generates the error TI1006 - output file will overwrite input file, and I cannot reference this into my .net project</p>
  
  <p>EDIT:</p>
  
  <p>There seems to be a problem with ADO and Win7 SP1. <a href="http://support.microsoft.com/kb/2517589" rel="nofollow">http://support.microsoft.com/kb/2517589</a> which would account for the deprecated error message (TI1033) I was getting, but not why VS was failing to create a CCW for the dll I can manually create a CCW via tlbimp.</p>
  
  <p>EDIT (12/03/28 10:40): </p>
  
  <p>So I have rebuilt the com dll with the suggested tlb. I can now successfully run </p>
  
  <pre><code>tlbimp mylib.dll
  </code></pre>
  
  <p>without getting any error messages and it appears to complete successfully. However, when I try and add a reference to that dll in VS, I still get the same original error message ( Library not registered (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))). I have checked the registry and the registration looks ok i.e. it is pointing to the correct path - I'm wondering if it is a permissions-type issue - but I am running vs as admin.</p>
  
  <p>EDIT (12/03/28 10:15):</p>
  
  <p>So I ended up creating a new completely new vm with the same environment - and it worked ok. So I've no idea what is going on other than some registry corruption perhaps!</p>
  
  <p>Many thx</p>
  
  <p>Simon.</p>