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

Welcome Forums General PowerShell Q&A Can't compile a c# project (powershell host) on windows 10 targeting .net 4.0

This topic contains 1 reply, has 2 voices, and was last updated by

 
Keymaster
2 years, 9 months ago.

  • Author
    Posts
  • #35381

    Participant
    Points: 0
    Rank: Member

    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 "system.management.automation" (version 3.0.0.0) could not be resolved, because it has a dependence to Microsoft.Management.Infrastructure.Native (version 1.0.0.0) 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 powershell.org and I hope this is the correct forum for my question.
    Thanks in advance
    Alex

  • #35438

    Keymaster
    Points: 1,638
    Helping HandTeam Member
    Rank: Community Hero

    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.

The topic ‘Can't compile a c# project (powershell host) on windows 10 targeting .net 4.0’ is closed to new replies.