Doesn't Windows warn me ...
You should definitely get a warning, but not from Windows, but from the CLR. The dialog is as follows , by clicking “Yes”, it automatically receives the required version of the framework, deployed and installed on the computer. The CLR performs this check by looking for the [TargetFramework] attribute embedded in the assembly. As noted, run the ildasm.exe file to verify this attribute. With the expectation that it is either absent or has a fairly low value, so the dialog does not start.
What is the best practice to solve this problem in general?
This is a procedural error; the assembly was not built correctly. You know with great certainty that the compiler used reference assemblies that are suitable only for version .NET 4.6. This needs to be tracked on the machine that built it, most likely it will be a build server. It wasn’t set up correctly, something like the setback that is so common when a civil engineer cuts corners by avoiding using a licensed copy of Visual Studio. Or, using free tools, Jenkins is a common disaster.
Besides the [TargetFramework] attribute being erroneous or missing, this particular loser is especially easy to call. All that is required is to use the assemblies in the c: \ windows \ microsoft.net \ directory as reference assemblies instead of the correct ones that require the targeting package and are installed in the c: \ program files (x86) \ reference assemblysies directory. This Q + A has more potential customers.
Fixing a build server tends to have many resistance points, best done as a tester to report an error. You also want to write one for broken catch-em-all exception handling, which makes it difficult to diagnose the problem.
source share