Can't compile a c# project (powershell host) on windows 10 targeting .net 4.0

I have a project which can be compiled without problems on windows 7. Now I am trying to move to windows 10 and the exact same project can not be compiled on windows 10.

I have a german environment so I will try to translate the error message.

The primary reference “” (version could not be resolved, because it has a dependence to Microsoft.Management.Infrastructure.Native (version which is build on .net framework 4.5.

because of this message i tried to change my target framework to point to .net 4.5. targeting 4.5 it works fine, but because of other assemblies I need to compile everything with .net 4.

As I mentioned, on a windows 7 machine the exact same code can be compiled without any issues.

It is my first post on and I hope this is the correct forum for my question.
Thanks in advance

The difference is that Win10 comes with, and only runs, PowerShell v5, which itself was compiled against the later .NET Framework version. Win7 can run a variety of PowerShell versions, which have their own .NET dependencies. This is something that developers are more or less constantly dealing with - you really have to get everything lined up against a particular version. In the case of Win10, because it can only run PowerShell v5, you’ll have to get everything happy running in that version.