降级.NET框架4.5至4在Visual Studio 2012的C ++ CLR支持DLL项目?

编程入门 行业动态 更新时间:2024-10-23 15:19:57
本文介绍了降级.NET框架4.5至4在Visual Studio 2012的C ++ CLR支持DLL项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

链接一个Visual C#.NET框架4.0支持的项目的时候,我加入了C ++ CLR DLL 4.5 .NET Framework中的一个参考,我得到这个错误。

I get this error when linking a Visual C# .NET framework 4.0 supported project as I added a reference of C++ CLR DLL with 4.5 .NET Framework.

error CS0246: The type or namespace name 'project' could not be found (are you missing a using directive or an assembly reference?)

这样一来,我如何在Visual Studio 2012降级.NET框架4.5到4.0这个C ++ CLR支持DLL项目?

As a result, how do I downgrade .NET framework 4.5 to 4.0 in Visual Studio 2012 for this C++ CLR supported DLL project?

我看这是原因前已。对于我的C ++,这个环节可以帮助我的事业msdn.microsoft/en-us/library/bb772098(v=vs.90).aspx

I have seen this before which was the cause. For my C++, this link may help out my cause msdn.microsoft/en-us/library/bb772098(v=vs.90).aspx

我刚刚发现了这个警告,以及:

I just discovered this warning as well:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3274: The primary reference "X" could not be resolved because it was built against the ".NETFramework,Version=v4.5" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.0".

人见过这个?所以,我怎么降级C ++ DLL?

Anyone seen this before? So how I downgrade the C++ DLL?

感谢

推荐答案

在C ++ IDE并不支持多目标的.NET项目。你需要手工编辑.vcxproj。关闭该项目,如果你把它打开,然后打开一个文本编辑器中.vcxproj。找到这一行:

The C++ IDE doesn't support multi-targeting for .NET projects. You'll need to edit the .vcxproj by hand. Close the project if you have it open and open the .vcxproj in a text editor. Locate this line:

<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>

和修改为V4.0。在VS再次打开项目项目+属性,公共属性,框架和参考。在列表中选择系统,检查相对路径属性。现在应该指向4.0版本。

and modify it to "v4.0". Open the project again in VS. Project + Properties, Common Properties, Framework and References. Select "System" in the list and check the Relative Path property. It should now point to the 4.0 version.

请提防显著的问题,其核心原因是,C ++ IDE并不支持多目标的。没有与 #using指令的问题,它加载组件从C:\ WINDOWS \ microsoft子目录。这将得到它加载.NET 4.5组件,而不是你想要的时候你的目标4.0 4.0组装。 4.0参考集存储在C:\ Program Files文件\引用程序集。这可能会导致非常难以诊断运行问题,4.5组件不与4.0程序集兼容。这是很容易避免在您自己的code使用#using但它用在包括/ msclr / marshal.h,包括/ vcclr.h头文件。如果使用这些头买者自负。

Do beware of a significant issue and the core reason that the C++ IDE does not support multi-targeting. There is a problem with the #using directive, it loads assemblies from the c:\windows\microsoft subdirectory. Which will get it to load a .NET 4.5 assembly instead of the 4.0 assembly that you want when you target 4.0. The 4.0 reference assemblies are stored in c:\program files\reference assemblies. This can cause very hard to diagnose runtime problems, the 4.5 assemblies are not that compatible with the 4.0 assemblies. It is easy enough to avoid #using in your own code but it used in the include/msclr/marshal.h and include/vcclr.h header files. Caveat emptor if you use these headers.

更多推荐

降级.NET框架4.5至4在Visual Studio 2012的C ++ CLR支持DLL项目?

本文发布于:2023-11-03 15:46:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1555486.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:框架   项目   Visual   NET   CLR

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!