locked
SSDT Deploy - deployment script - Microsoft.SqlServer.Dac.dll - Could not load file or assembly RRS feed

  • Question

  • When running a deployment powershell script generated from SSDT we are failing to load the dacpac assembly (Microsoft.SqlServer.Dac.dll.)

    We have tried altering the powershell.exe.config configuration files and adding in the v4.0 runtime but this hasn't worked.

    <?xml version="1.0" encoding="utf-8" ?> 
    <configuration> 
        <startup useLegacyV2RuntimeActivationPolicy="true"> 
            <supportedRuntime version="v4.0" />    
        </startup> 
    </configuration>

    The error message is:

    Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\Microsoft.SqlServer.Dac.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
    At C:\Work\deploy_db.ps1:159 char:8
    + throw <<<<  $_.Exception 
        + CategoryInfo          : OperationStopped: (:) [], BadImageFormatException
        + FullyQualifiedErrorId : Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\Microsoft.SqlServer.Dac.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

    Has anyone overcome these difficulties?!

    Appreicate any help, 

    Regards

    Rob.

    Tuesday, July 15, 2014 12:07 PM

Answers

  • Your powershell version is running .Net 2.0 but needs to run 4.0 or higher. See this answer or use a newer version of powershell to fix this.

    Kevin

    • Marked as answer by psirr-MSFT Wednesday, July 16, 2014 4:40 PM
    Tuesday, July 15, 2014 5:21 PM

All replies

  • Your powershell version is running .Net 2.0 but needs to run 4.0 or higher. See this answer or use a newer version of powershell to fix this.

    Kevin

    • Marked as answer by psirr-MSFT Wednesday, July 16, 2014 4:40 PM
    Tuesday, July 15, 2014 5:21 PM
  • Thank you very much for the suggestion.

    I found just prior that it was resolved by adding a Path to the DAC, i.e.

    Add-Type -Path "C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\Microsoft.SqlServer.Dac.dll"

    I think this was the resolution!

    Wednesday, July 16, 2014 4:44 PM