'Runtime newer' error when attempting to load WebServices DLL into PowerShell

Version 1

    Verified Product Versions

    AppSense Management Center 8.4

    Introduction

    When attempting to load the ManagementConsole.WebServices.dll module into PowerShell an error message is received stating

    "Could not load file or assembly 'file:///C:\Program Files\AppSense\Management Center\Console\ManagementConsole.WebServices.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded."




    Detail

    By default PowerShell uses the v2 .NET framework (as can be seen by executing $PSVersionTable and checking the CLRVersion) whilst the ManagementConsole.WebServices.dll requires the v4 .NET framework.

    To enable PowerShell to use the v4 .NET framework create a 'powershell.exe.config' file with the below content and copy to the following locations:

    • C:\Windows\System32\WindowsPowerShell\v1.0
    • C:\Windows\SysWOW64\WindowsPowerShell\v1.0 (if the machine is 64 bit)



     

    <?xml version="1.0"?>

    <configuration>

        <startup useLegacyV2RuntimeActivationPolicy="true">

             <supportedRuntime version="v4.0.30319"/>       

             <supportedRuntime version="v2.0.50727"/>       

        </startup>

    </configuration>

     

    Reopen the PowerShell process, check the CLRVersion loaded in PowerShell.exe is now v4, and the script succeeds.