错误:程序集“c:\MyAssembly.dll”无法转换为类型库

发布于 2024-09-15 21:49:02 字数 448 浏览 4 评论 0原文

我正在尝试构建我的项目,但当项目构建并且“注册 COM 互操作”属性被勾选时,我突然开始收到以下错误。

程序集“c:\MyAssembly.dll”无法转换为类型库。类型库导出器在处理“SomeType,MyAssembly”时遇到错误。错误:引用的类型是在托管组件中定义的,该组件是从无法加载的类型库导入的(类型:“OtherType”;组件:“c:\OtherAssembly.dll”)。

团队中没有其他人遇到此错误,只有我一个人遇到此错误!显然,我对我的机器做了一些奇怪的事情,但是完全删除/删除并重新添加我能想到的所有内容的强力方法没有任何区别,因此我不得不真正理解这个错误(真是太麻烦了!)

所以:

  • 此错误实际上是什么意思意味着
  • 接下来我应该在哪里查找有关错误的其他/更具体的诊断信息?

I'm trying to build my project and I've suddenly started getting the following error when the project builds and the "Register for COM interop" property is ticked.

The assembly "c:\MyAssembly.dll" could not be converted to a type library. Type library exporter encountered an error while processing 'SomeType, MyAssembly'. Error: Referenced type is defined in managed component, which is imported from a type library that could not be loaded (type: 'OtherType'; component: 'c:\OtherAssembly.dll').

Nobody else on the team gets this error, its just me! Clearly I have done something odd to my machine, however the brute force approach of completely removing / deleting and re-adding everything I could think of made no difference, and so I am resigned to actually understanding this error (what a drag!)

So:

  • What does this error actually mean
  • Where should I look next for additional / more specific diagnostic information on what is wrong?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

楠木可依 2024-09-22 21:49:02

就我而言,我有一个使用 regasm 注册的 com 公开 dll(我更改了 guid)。我必须使用以下命令取消注册程序集,然后才能成功构建项目。

c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>regasm /u "C:\some-vs-project\bin\Debug\some-vs-dll.dll"

另外,如果您更改了 GUID,则需要确保您在 assembly.cs 中不使用与您在类中使用的 GUID 相同的 GUID。我在类声明和程序集中使用了相同的 GUID,这也会导致相同的错误。

In my case, I had a com exposed dll (I changed the guid) that was registered using regasm. I had to use the following command to un-register the assembly and then I was able to build the project successfully.

c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>regasm /u "C:\some-vs-project\bin\Debug\some-vs-dll.dll"

Also if you changed the GUID you need to make sure your NOT using the same GUID in the assembly.cs that your using in your class. I used the same GUID in both the class declaration and assembly and that causes the same error as well.

み格子的夏天 2024-09-22 21:49:02

我有完全相同的问题。通过将目标平台从 x86 更改为 Any CPU,它被神奇地修复了

I had exactly the same problem. It was fixed magically by changing the target platform from x86 to Any CPU

恍梦境° 2024-09-22 21:49:02

我有这个问题。我只是做了同样的事情,gactutil /u(用于卸载)和gacutil /i(用于安装),问题就解决了

I had this problem to. I just did the same, gactutil /u (for the uninstall) and gacutil /i (for the install) and the problem was solved

飘落散花 2024-09-22 21:49:02

就我而言,发生此错误是因为我通过 regsvr32 手动注册了 COM 服务器。当我后来移动包含 dll 的文件夹时,我忘记更新注册表(即取消注册并重新注册 COM 服务器)。

重新注册服务器修复了该错误。

In my case, this error occured because I had manually registered a COM-server via regsvr32. When I later moved the folder containing the dll, I forgot to update the registry (i.e. unregister and re-register the COM-server).

Reregistering the server fixed the error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文