简体   繁体   English

我可以在同一解决方案中使用.NET Framework 4.5.2和4.6.2的另一个项目吗?

[英]Can I have a project which uses .NET Framework 4.5.2 and another project with 4.6.2 in the same solution?

我想创建一个VS解决方案,其项目使用.NET Framework 4.5.2,另一个项目使用4.6.2在同一个VS解决方案中。

Having projects using different versions of .Net in the same solution is fine. 在同一解决方案中使用不同版本的.Net的项目很好。 When you add references between projects you may have issues. 在项目之间添加引用时,可能会出现问题。 Projects can reference other projects that are at-or-below the version of the referencing project. 项目可以引用位于引用项目版本之下或之下的其他项目。 Ie, a .Net 4.5 project can reference .Net 4.5 projects and lower. 即,.Net 4.5项目可以参考.Net 4.5项目并降低。

Now if you add a reference to a .Net 4.6.2 project to the .Net 4.5 project, it will not resolve or in other words, the reference simply won't work. 现在,如果您将.Net 4.6.2项目的引用添加到.Net 4.5项目中,它将无法解析,换句话说,引用将无法正常工作。 Unfortunately, Visual Studio won't stop you (at least at the time of writing) so you need to look for a couple visual cues to let you know something is amiss. 不幸的是,Visual Studio不会阻止你(至少在撰写本文时),所以你需要寻找几个视觉提示,让你知道有些不对劲。 One is in the references list under the project in Visual Studio; 一个是在Visual Studio中的项目下的引用列表中; an exclamation point will show next to your reference like this: 感叹号将显示在您的参考旁边,如下所示:

参考视觉提示警告

The other cue will be compile time warnings like this: 另一个提示将是编译时警告,如下所示:

编译时间警告

You'll want to keep an eye out for this since it will most likely cause run time issues if you use that assembly in the referencing project which can be a headache to troubleshoot. 您需要密切注意这一点,因为如果您在引用项目中使用该程序集,这很可能会导致运行时问题,这可能是一个令人头疼的问题。

Yes, you can have them in the same solution without impact. 是的,您可以将它们放在同一个解决方案中而不会产生任 Now if you mixed versions referencing each other than it gets into a grey area. 现在,如果您混合引用彼此的版本而不是进入灰色区域。

If your code is referencing a library that is the same or less than your target framework than you are usually just fine but you should also check if there are any known issues just to be sure. 如果您的代码引用的库是与您的目标框架相同或更少的库,那么您通常也可以使用,但您还应该检查是否存在任何已知问题。 On the reverse side when your code is ref libraries with higher target framework than you can expect some weird things and unexpected errors to crop up. 反过来,当您的代码是具有更高目标框架的ref库时,您可能会发现一些奇怪的事情和意外错误。

It depends. 这取决于。 I just tried it with 4.5.2 and 4.7.1. 我只是尝试了4.5.2和4.7.1。 As long as the references are in place, you can reference an item in the 4.5.2 framework code from the newer version (4.7.1 in my case). 只要引用到位,您就可以从较新的版本(在我的例子中为4.7.1)中引用4.5.2框架代码中的项目。 However I don't think it will work the other way around. 但是,我认为它不会相反。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以在版本4.6.2的Visual Studio项目中使用针对4.5.1 .net框架的库吗? - Can I use a library which is targeted to 4.5.1 .net framework in a visual studio project of version 4.6.2 将 Web 应用项目添加到我的解决方案中,并且解决方案中的其他项目已经使用 .net 框架,我可以将 .net 核心用于新项目吗? - adding a web app project to my solution, and the other projects in the solution already use .net framework, can I use .net core for the new project? TLS 1.2 .net 4.6.2项目 - TLS 1.2 .net 4.6.2 project 我可以从同一解决方案中的另一个项目访问项目的类和方法吗? - Can I access a project's class and methods from an another project in the same solution? 在同一个解决方案中,如何从另一个项目获得相对于项目的相对路径? - How can I get the relative path to a project from another project in the same solution? 我可以从同一解决方案中的不同项目访问另一个项目的嵌入式资源吗? - Can I access another project's Embedded Resource from a different project in the same solution? 如何运行相同解决方案中的项目? - How can I run a project that is in the same solution? 我们如何从.net Web应用程序连接到Azure SQL数据库,该Web应用程序使用Azure MSI在.net Framework 4.6.2中开发的实体框架 - how can we connect to azure sql database from .net web application which uses entity framework developed in .net framework 4.6.2 by azure MSI 如何将ASP .NET Identity / Identity Framework DbContext类合并到另一个Assembly /项目上的DbContext类 - How can I merge ASP .NET Identity/ Identity Framework DbContext class to my DbContext class which is on another Assembly/ Project .NET 核心重定向到 Controller 在同一解决方案下的另一个项目中 - .NET Core Redirect to Controller in another Project under same Solution
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM