如何修复致命错误 C1113: #using failed on ‘Mylib.lib’

发布于 2024-08-19 04:34:40 字数 637 浏览 1 评论 0原文

我有一个项目,它使用 C++/CLI 来实现 GUI 和一些后台处理来与传感器通信。我已经完成了所有工作,并且我们用来与传感器进行通信的许多通信内容都位于 .dll 中。问题是我想将该库合并到主可执行文件中,以避免担心分发 .dll。

我有一个演示项目,使用 .lib 可以正常工作,但是当我尝试切换 mani 代码体以生成 .lib 而不是 .dll 时,出现以下错误

1>------ Build started: Project: MyTool, Configuration: Debug Win32 ------
1>Compiling...
1>stdafx.cpp
1>.\stdafx.cpp : fatal error C1113: #using failed on 'c:\projects\MyTool\debug\MyLib.lib'

: microsoft.com/en-us/library/ms173557%28VS.80%29.aspx" rel="nofollow noreferrer">一些谷歌搜索表明当您没有应用 MSIL 开关时会发生这种情况,但是它肯定在图书馆项目中。

我的演示项目和真实项目中都混合了托管和非托管代码,因此我真的很难找出问题所在。

任何建议都将非常感激!

I have a project which uses C++/CLI to implement a GUI and some background processing to talk to a sensor. I've got that all working and a lot of the comms stuff which we use to communicate the the sensor sits in a .dll. The problem is that I'd like to combine the library into the main executable to avoid having to worry about distributing .dlls.

I've got a demo project which works fine using a .lib but when I try and switch the mani code body to produce a .lib instead of .dll I get the following error:

1>------ Build started: Project: MyTool, Configuration: Debug Win32 ------
1>Compiling...
1>stdafx.cpp
1>.\stdafx.cpp : fatal error C1113: #using failed on 'c:\projects\MyTool\debug\MyLib.lib'

A bit of googling suggests this happens when you've not got the MSIL switch applied, but it's definitely in there in the library project.

I have a mixture of managed and unmanaged code in both my demo project and the real thing so I'm really struggling to see what the problem is here.

Any suggestions would be very gratefully received!

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

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

发布评论

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

评论(3

ゞ记忆︶ㄣ 2024-08-26 04:34:40

我猜测了一下,但我怀疑“MyTool”项目将“MyLib”项目作为其“引用”之一(“项目”菜单>>属性>>通用属性>>引用)。

当您将 MyLib 项目的类型更改为 LIB 而不是 DLL 时,您需要从项目引用中删除“MyLib”。然后更新解决方案的项目依赖项(“项目”菜单>>“项目依赖项...”),以便 MyTool 依赖于 MyLib。

I am guessing a bit, but I suspect the "MyTool" project has the "MyLib" project as one of its "references" ("Project" menu >> Properties >> Common Properties >> References).

When you change the type of the MyLib project to a LIB instead of a DLL, you need to remove "MyLib" from the project references. You then update the project dependencies of the solution ("Project" menu >> "Project Dependencies...") so that MyTool depends on MyLib.

故事未完 2024-08-26 04:34:40

我也遇到了这个。失败的原因是我正在将本机/托管 C++ DLL 编译为目标 .NET 4.0。我#using 的 DLL 是一个 .NET 2.0 DLL。因此,即使路径和文件名完美对齐,它还是失败了。在这种情况下,错误消息绝对没有任何帮助。
我通过将独立DLL更新为.NET 4.0来解决这个问题。这样两个程序集都使用相同的 .NET 框架。

I also ran into this. The reason it was failing was because I was compiling my native/managed C++ DLL to target .NET 4.0. And the DLL I was #using was a .NET 2.0 DLL. As such it was failing, even though the paths and file names lined up perfectly. In this case the error message was absolutely of no help at all.
I solve it by updating the independent DLL to .NET 4.0. So that both assemblies were using the same .NET framework.

我偏爱纯白色 2024-08-26 04:34:40

如果您链接到混合模式(托管/本机)DLL,您可能会收到此错误。如果项目使用 CLR,即使源文件之一不使用 CLR,您也不应该这样做。但无论如何,如果是这种情况,请尝试从项目|属性|通用属性|引用中删除引用,然后重新添加它。

If you are linking to a mixed mode (managed/native) DLL you may get this error. Which you shouldn't if the project uses CLR even if one of the source files doesn't. But anyway, if that is the case, then try removing the reference from Project|Properties|Common Properties|References and then re-adding it.

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