Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

.net

I would like to create a VS Solution with a project which uses .NET Framework 4.5.2 and another project with 4.6.2 in the same VS Solution.

like image 679
John Abel Avatar asked Jan 29 '23 09:01

John Abel


1 Answers

Having projects using different versions of .Net in the same solution is fine. 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. I.e., a .Net 4.5 project can reference .Net 4.5 projects and lower.

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. 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. One is in the references list under the project in Visual Studio; an exclamation point will show next to your reference like this:

Reference visual cue warning

The other cue will be compile time warnings like this:

Compile time warnings

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.

like image 123
Always Learning Avatar answered Feb 01 '23 16:02

Always Learning