SsdtHelper.DeployDacPacWithOptions() fails with System.MissingMethodException: Method not found: 'Void Microsoft.SqlServer.TransactSql'

Ron Anoshi 10 Reputation points
2023-01-23T12:08:46.3933333+00:00

I have a .NET Framework 4.6.1 (upgrading to 4.6.2 doesn't solve it) project that uses DacServices to deploy my database's SSDT on a Docker container.
This eventually uses the following code:



using (var fileStream = new FileStream(dacpacPath, FileMode.Open, FileAccess.Read))
            using (var dbPackage = DacPackage.Load(fileStream, DacSchemaModelStorageType.Memory, FileAccess.Read))
            {
                return dbServices.GenerateDeployScript(dbPackage, targetDbName, dbDeployOptions);
            }

This line fails with the following error:

System.MissingMethodException
  HResult=0x80131513
  Message=Method not found: 'Void Microsoft.SqlServer.TransactSql.ScriptDom.SqlScriptGeneratorOptions.set_AllowExternalLibraryPaths(Boolean)'.
  Source=Microsoft.Data.Tools.Schema.Sql
  StackTrace:
   at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentPlanGenerator.ScriptGeneratorFacade..ctor(DeploymentContext context, Func`1 getTargetDboUserSecurityId)
   at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentPlanGenerator.OnInitialize(SqlDeployment engine)
   at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.InitializePlanGeneratator()
   at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.CreateController(Action`1 msgHandler)
   at Microsoft.SqlServer.Dac.DacServices.CreateController(SqlDeployment deploymentEngine, ErrorManager errorManager)
   at Microsoft.SqlServer.Dac.DacServices.<>c__DisplayClass30.<CreateDeploymentArtifactGenerationOperation>b__2e(Object operation, CancellationToken token)
   at Microsoft.SqlServer.Dac.Operation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
   at Microsoft.SqlServer.Dac.ReportMessageOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
   at Microsoft.SqlServer.Dac.OperationExtension.Execute(IOperation operation, DacLoggingContext loggingContext, CancellationToken cancellationToken)
   at Microsoft.SqlServer.Dac.DacServices.GenerateDeployScript(DacPackage package, String targetDatabaseName, DacDeployOptions options, Nullable`1 cancellationToken)
   at Payoneer.ServicesInfra.TestingUtils.DbSsdtDeployer.SsdtHelper.CreateSsdtDeployScript(String dacpacPath, String targetDbName, DacDeployOptions dbDeployOptions, DacServices dbServices) in...

This somehow passes on the build server and someone else's machine, so it's likely a version mismatch, but of what, and how?
Help appreciated.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,193 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,319 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Ron Anoshi 10 Reputation points
    2023-05-04T14:37:47.1266667+00:00

    Hi all,

    Posting a temporary fix for this which worked for me (and some others):
    Delete the following DLL (need to close VS & SSMS for this):

    C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.TransactSql.ScriptDom\v4.0_15.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.TransactSql.ScriptDom.dll

    And rerun your failing code.

    Thanks to Batia P. who found this fix.
    Ron.

    2 people found this answer helpful.
    0 comments No comments

  2. Zohar Gelman Biran 0 Reputation points
    2023-02-16T10:25:18.8966667+00:00

    The same issue is happening to me.

    The DacDeployOptions I set are:

    • CreateNewDatabase = true
    • BlockOnPossibleDataLoss = false
    • BlockWhenDriftDetected = false
    • Some SqlCommandVariableValues: DefaultDataPath, SSDT_repo, debug.

    The failure happens when calling the DacServices.GenerateDeployScript(..).
    Also, for some reason the same code works when running on .Net Core 3.1

    0 comments No comments

  3. Seeya Xi-MSFT 16,416 Reputation points
    2023-02-28T08:24:32.74+00:00

    Hi @Ron Anoshi ,

    This error typically occurs when there is a mismatch between the version of the SQL Server Data Tools (SSDT) that you are using and the version of the SQL Server you are targeting. The AllowExternalLibraryPaths property was introduced in a later version of SQL Server than the version you are targeting.

    To resolve this issue, you should ensure that you are using a version of SSDT that is compatible with the version of SQL Server you are targeting. You may need to update either SSDT or SQL Server to a compatible version.

    Please refer to this:

    https://learn.microsoft.com/en-us/sql/ssdt/release-notes-ssdt?view=sql-server-ver16

    If this does not help you, you can add more information, such as the SSDT version.

    Best regards,

    Seeya


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".