构建应用程序时出现程序集错误 - 遇到多个版本的程序集
我今天像每天一样工作,当我尝试构建我的项目时,我收到了这个错误:
遇到了多个版本 带 GUID 的程序集 '00020430-0000-0000-c000-000000000046'。 尝试预导入其中之一 组件。
它说问题出在我的应用程序根目录中的 TlbImp 文件中。唯一的问题是我的项目中没有这样的文件,而且据我所知从未有过。
我正在使用 Visual Studio 2010 处理 Web 应用程序(不确定此信息是否有帮助,但无论如何)。
I was working today as I do everyday, when I tried to build my project and I got this error:
Encountered multiple versions of the
assembly with GUID
'00020430-0000-0000-c000-000000000046'.
Try pre-importing one of these
assemblies.
It says the problem is in the file TlbImp that's in the root directory of my application. The only problem is that I don't have such file in my project and as far as I remember never had.
I am working with a Web Application with Visual Studio 2010 (not sure if this information helps but well, whatever).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
谢谢@DavRob,但这不是我正在寻找的答案。 @dev_Gabriel 我设法修复了它,以下是对我有用的步骤:
Thanks @DavRob but it wasn't the answer I was looking for. @dev_Gabriel I managed to fix it, here are the steps that worked for me:
有一个 Microsoft connect Bug 已填充
它说有问题对 COM 组件的引用。
Tlbimp 是类型库导入器。 Visual Studio 使用它来生成对您添加的 COM 库的引用的互操作程序集。
There is a Microsoft connect Bug filled for that
It said that there a problem with a reference to an COM component.
Tlbimp is the Type Library Importer. Visual Studio use it to generate the interop assembly of references to COM libraries you added.
只是添加到 @JeremyThompson 的响应:
我的问题是由于引用 COM 对象,通过“添加引用”并浏览到应用程序的 .exe(即 C:\Program Files (x86)\ProFile\profile.exe )。这添加了一个“Interop.Profile.dll”(显然这会有所不同,具体取决于您尝试访问的 SDK)引用,该引用位于 obj/Debug 文件夹中,如 @JeremyThompson 所描述。
在我的具体情况下,我在两个项目中引用了此 Interop.Profile.dll,其中一个项目没有出现上述错误并成功构建。我转到 obj/Debug 文件夹以获取成功构建的项目,并将 Interop.Profile.dll 复制到我的解决方案的 DLL 文件夹(这只是我创建的一个文件夹,用于将所有程序集保存在一个位置,但从技术上讲,您可以将您的COM DLL 位于 obj/Debug 文件夹之外的任何位置),然后将我的两个项目的引用更改为指向位于我的 DLL 文件夹中的 Interop.Profile.dll,而不是 obj/Debug 文件夹中的那个。
一旦我这样做了,我的应用程序就成功构建了(使用重建,或清理然后构建)。
显然,我的案例非常具体,但希望它对那里的人有所帮助。
Just to add to @JeremyThompson's response:
My issue was due to referencing a COM object, by going "Add Reference" and browsing to the the .exe for the application (i.e. C:\Program Files (x86)\ProFile\profile.exe). This added an "Interop.Profile.dll" (obviously this will be different depending on the SDK you're trying to access) reference which was located in the obj/Debug folder as described by @JeremyThompson.
In my specific case, I had this Interop.Profile.dll referenced in two projects, one of which was not getting the error above and built successfully. I went to the obj/Debug folder for the successfully built project and copied the Interop.Profile.dll to my Solution's DLL folder (this is just a folder I created to keep all of my assemblies in one place, but you could technically put your COM DLL anywhere outside of the obj/Debug folder) and then changed the references of both my projects to point at the Interop.Profile.dll which is located in my DLLs folder, rather than the one in the obj/Debug folder.
Once I did this, my application built successful (using Rebuild, or Clean and then Build).
Obviously, my case is pretty specific, but hopefully it helps someone out there.
我有同样的错误。我意识到我在两个不同的位置引用了同一个 .dll 两次。
因此,我所做的就是删除对 .dll 的所有引用,然后从一个位置再次添加它。
这解决了错误。
I had the same error. I realised that I was referencing the same .dll twice in two different locations.
So all I did was delete all the references to the .dll, and added it again from a single location.
This resolved the error.
我今天在将 VS 2008 项目迁移到 VS 2013 时遇到了这个问题,还有另一个不同的转折。我花了一段时间才弄清楚,所以它可能对其他人有帮助。
我有一个包含 10 个左右项目的解决方案。其中一个项目是 VB,它引用了带有 GUI 的旧 OCX。要创建所需的互操作引用,您需要将 OCX 拖到 Winform 上,该 Winform 会拉入其他引用并创建所需的 AX 互操作引用。所有这些互操作 dll 都是在 ...\obj\debug\ 路径中创建的。
我收到了几个“多版本”错误,但不是来自具有 COM 引用的项目,而是来自引用 VB 项目的另一个 C# 项目。
为了解决这个问题,我将 VB 项目创建的互操作文件复制到 C# 项目的 ...\obj\debug\ 文件夹中。
这有点痛苦,因为每次清理项目时,都需要重新复制文件,但至少现在可以了。请注意,您不能将 AxInterop 移动到其他地方并手动引用它,因为它会造成麻烦。
感谢@crunchy 给我这个想法。
I just had this today when migrating a VS 2008 project to VS 2013, with another different twist. Took me a while to figure out, so it might help someone else.
I have a solution with 10 or so projects in it. One of the projects is VB which references an old OCX with a GUI. To create the required interop references, you need to drag the OCX onto a Winform which pulls in other references as well as creating the required AX interop ref. All these interop dlls are are created in in the ...\obj\debug\ path.
I was getting several "multiple version" errors, but not from the project with the COM references but from another C# project that referenced the VB project.
To get rid of this, I copied the interop files created by the VB project to the ...\obj\debug\ folder of the C# project.
It's a bit of a pain, since each time you clean the project, you need to re-copy the files, but at least it works now. Note that you cannot move the AxInterop somewhere else and referecne irmanually reference it as it screws thing sup a treat.
Thanks @crunchy for giving me the idea.