Mixed .NET targets a problem on Win10Ent but not Windows Datacenter 2016

Viewed 110

I have a .NET solution that contains 11 projects. A few of these projects target .NET 3.5, a few target 4.5, and a few target 4.7. On Windows Datacenter 2016, these mismatches cause no problems and all projects in the solution compile.

However, on Windows 10 Enterprise, several of the projects will not compile until I change all projects to target .NET 4.7. (I don't think there's anything special about 4.7 - I could probably have them all target 4.5 or 4.7.2 or whatever, and they would compile.) After all projects target .NET 4.7, all projects build with no problems.

The source for these projects are closely controlled by higher-ups and there's no way I can get them to change all the targets in the short term, and they may have reasons for not wanting to. So in the short term, getting the master source changed is not an option.

When the projects target mixed frameworks on Win10, the compile error I get is:

The type or namespace 'Legacy' could not be found.

"Legacy" is the name of a custom class that exists within one of these 11 projects, and it's one that targets .NET 3.5. The strange thing is, I can double-click the error and be brought to the line of code that references the Legacy class...I can Go To Definition on Legacy, and VS takes me right to that Legacy class. So the compiler obviously can find the class even though it says it can't find it. Apparently the target-runtime mismatch is freaking out the compiler in some way.

But why is the mismatch not a problem on Win2016 Datacenter?

Important

  1. On both Win2016 and Win10 I'm using Visual Studio 2019 (16.6.1) to compile.
  2. Both Win2016 and Win10 have identical versions of .NET frameworks installed. They both have 4.7, 3.5, and several others.
  3. The source code is identical on both - no differences.

Question: What can I do to get the mixed-target projects to compile without needing to change all the targets to 4.7? (Why does the mixture work fine on Windows 2016 Datacenter and not on Windows 10 Enterprise?)

0 Answers
Related