如何调试失败的呼叫转换AssemblyTotyPelib()?

发布于 2025-01-24 22:39:46 字数 1304 浏览 3 评论 0原文

函数convertAssemblyTotyPelib来自汇编system.runtime.interopservices是一个黑匣子,它给我带来了很多头痛。

在大多数情况下,此调用

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

成功,但有时会引发此例外:

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').

很明显,我的依赖组件中的至少一个未正确安装/注册。

但是,在删除了GAC中的所有内容,从注册表中擦洗了每个相关条目,并从头开始重建所有内容之后,上述电话再次成功。

我厌倦了将公牛推土机驶过客厅,只是因为墙壁上缺少一个指甲

我尝试运行汇编绑定日志查看器时,将呼叫发出convertsemblytotypelib ,但没有记录任何内容。

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 Visual Studio,看起来还不错。最值得注意的是,它具有错误消息中提到的icomtask接口。

有任何线索如何固定指向导致错误的组件?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文