带有模板的Visual Studio C ++/CLI神秘错误 [英] Visual Studio C++/CLI Mysterious Error With Template

查看:53
本文介绍了带有模板的Visual Studio C ++/CLI神秘错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我一直试图在Visual Studio 2015中制作一个C ++ DLL,这花了一段时间,因为我对Visual Studio不太满意.

Well, I've been trying to make a C++ DLL in Visual Studio 2015, which took a while since I'm not very good with Visual Studio.

我需要访问.NET库,尤其是System :: Management.(由于C ++的实现不佳,编写代码比原本要难一些,但至少有一个.)

I need to access the .NET libraries, specifically System::Management. (Writing the code was a little harder than it needed to be due to a poor C++ implementation, but at least it has one.)

我修复了明显的错误,最后发现我必须在项目属性中启用CLR,然后使用References-> Add Reference选择相关的库.但是毕竟,这只是给了这个奇怪的错误:

I fixed obvious errors and finally figured out I had to enable CLR in the project properties and then select the related libraries with References->Add Reference. But after all that, now it's just giving this weird error:

LNK1104: cannot open file 'MSCOREE.lib'

编译器在任何下方均未显示红色波浪线,并且错误声明该行为"1",文件为"LINK",因此那里没有帮助.

The compiler doesn't show red wavy lines below anything, and the error claims the line is "1" and the file is "LINK", so no help there.

我以为我可能在某个地方弄乱了项目配置,所以我创建了一个新项目并将代码移到了上面.错误仍然发生.如果我关闭CLR并注释掉了.NET依赖的代码,则构建成功完成而没有错误.

I thought I probably messed up the project configuration somewhere, so I created a new project and moved the code over. The error still happened. If I turned off CLR and commented out the .NET-dependent code, the build succeeded without errors.

因此,我尝试通过模板(Visual C ++-> Win32控制台应用程序)创建一个新项目,然后启用CLR,然后再执行其他操作.然后,我再次尝试,选择了不同版本的.NET Framework.

So I tried creating a new project from template (Visual C++ -> Win32 Console Application) and then enabling CLR before doing anything else. Then I tried again, selecting different versions of .NET framework.

最后,我尝试使用模板(Visual C ++-> CLR-> CLR控制台应用程序)创建一个项目,然后立即构建它.我的意思是根本不做任何其他事情.它仍然给出相同的错误!

Finally, I tried creating a project with template (Visual C++ -> CLR -> CLR Console Application) and building it immediately. I mean literally without doing ANYTHING ELSE. It still gave the same error!

LNK1104: cannot open file 'MSCOREE.lib'

到底是怎么回事?我在这里做错了,还是VS2015刚刚坏了?

What on earth is going on? Am I doing something wrong here, or is VS2015 just broken?

推荐答案

我遇到了同样的问题.安装".NET Framework 4.6.1 SDK" 解决了该问题.注意版本号,从项目配置文件中获取

I had the same problem. Installing ".NET Framework 4.6.1 SDK" solved the problem. Pay attention to the version number, take it from your project configuration files

这篇关于带有模板的Visual Studio C ++/CLI神秘错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆