简体   繁体   中英

Installing .NET 4.5.2 on development machine causes error with System.Management.Automation.dll

After I installed the framework version 4.5.2 on my development machine, I opened one of my websites in VS2010. I chose to NOT upgrade it, and have verified that the target framework is 3.5, but when I try and build, I get the error

error BC32206: The project currently contains references to more than one version of System.Core, a direct reference to version 3.5.0.0 and an indirect reference (through 'System.Management.Automation.PSObject') to version 4.0.0.0. Change the direct reference to use version 4.0.0.0 (or higher) of System.Core.

For a variety of reasons, I do not want to upgrade the project to v4, and the version of System.Management.Automation.dll remains the same as before (6.1.7601.17514, dated 11/20/2010)

The problem appears when I'm running the code:

                For Each r As PSObject In powerShellObject.Invoke
                    Debug.Print(r.ToString)
                    returnValue += r.ToString
                Next

Any insight would be appreciated.

Try adding this to your web config file:

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Management.Automation"
                          publicKeyToken="31bf3856ad364e35"
                          culture="neutral" />
        <publisherPolicy apply="no" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

There is a publisher policy for SMAdll 1.0 that redirects it to 3.0 which is bound to .NET 4.0.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM