MSI cant load .dll Error: 0x8007007E wix installer

MSI cant load .dll Error: 0x8007007E wix installer

我正在尝试在自定义操作 wix 中执行此操作:

string sqlConnectionString = @"Server=MyInstanceName;Trusted_Connection=True;MultipleActiveResultSets=true";
string script = "...";
Microsoft.Data.SqlClient.SqlConnection conn = new Microsoft.Data.SqlClient.SqlConnection(sqlConnectionString);
Server server = new Server(new ServerConnection(conn));
server.ConnectionContext.ExecuteNonQuery(script);

它在控制台应用程序中工作,但是当我 运行 msi 时它抛出:

Failed to connect to server MyInstanceName. Could not load DLL 'Microsoft.Data.SqlClient.SNI.x86.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

当我使用 Orca 时,我看不到这个 .dll。

我该如何修复它?

这是库问题 Microsoft.SqlServer.Server。我更改了库以在 System.Data.SqlClient.

上编写 sql 命令

https://github.com/dotnet/runtime/issues/16048