[英]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.