How to debug failed calls to ConvertAssemblyToTypeLib()?

85 views Asked by At

The function ConvertAssemblyToTypeLib from assembly System.Runtime.InteropServices is a black box that is giving me a lot of head aches.

In most cases, this call

ITypeLibConverter tlbConv = new TypeLibConverter();
ITypeLib tlb = (ITypeLib)tlbConv.ConvertAssemblyToTypeLib(asm, tlbname, 0, this);

succeeds, but sometimes it throws this exception:

System.Runtime.InteropServices.COMException
HResult=0x80131163
Type library exporter encountered an error while processing 'MyType1.SendSetAsync(#0), MyType1'.
Error: Referenced type is defined in managed component, which is imported from a type library that could
not be loaded (type: 'MyType2.Interop.IComTask'; component:
'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\MyType2.Interop\v4.0_3.4.30000.0__nnnnnnnnnnnnnnnnn\MyType2.Interop.dll').

It's obvious that at least one of my dependent components is not installed/registered correctly.

But after removing everything from the GAC, scrubbing every related entry from the registry, and rebuilding everything from scratch, the above mentioned call succeeds again.

I'm sick and tired of driving the bull dozer through my living room just because a single nail is missing in the wall.

I tried running Assembly Binding Log Viewer while issuing the call to ConvertAssemblyToTypeLib but that did not record anything.

The assembly C:\Windows\Microsoft.Net\assembly\GAC_MSIL\MyType2.Interop\v4.0_3.4.30000.0__nnnnnnnnnnnnnnnnn\MyType2.Interop.dll does exists, I can open it in the object browser of Visual Studio and it looks just fine. Most notably it has the IComTask interface mentioned in the error message.

Any clues how I can pin point the component that causes the error?

0

There are 0 answers