首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在具有多个依赖项的Wix中添加自定义操作

在具有多个依赖项的Wix中添加自定义操作
EN

Stack Overflow用户
提问于 2021-03-23 11:56:36
回答 2查看 196关注 0票数 1

当我尝试使用C#动态链接库在Wix中添加自定义操作时遇到问题。我有一个用于检查Postgresql服务器连接的自定义操作,在C#项目中,我使用Npgsql来检查它。使用Npgsql ver 3.1.0一切都没问题。但当我将Npgsql升级到版本5.0.3 (最新版本)时,再次构建MSI安装程序,点击按钮运行自定义操作,出现错误

代码语言:javascript
复制
Could not load file or assembly 'System.Threading.Tasks.Extensions'

我知道在新版本中它需要System.Threading.Tasks.Extensions。但是我不知道如何嵌入到我的自定义动作DLL中。

以下是ver 5.0.3的依赖关系:

已更新,这是发生错误时的完整日志

代码语言:javascript
复制
System.IO.FileLoadException: Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   at Npgsql.ConnectorPool..ctor(NpgsqlConnectionStringBuilder settings, String connString)
   at Npgsql.NpgsqlConnection.GetPoolAndSettings()
   at Npgsql.NpgsqlConnection.set_ConnectionString(String value)
   at Npgsql.NpgsqlConnection..ctor(String connectionString)
   at OmsCustomAction.OmsCustomActions.TestConnection(PGInfo pgServer, String& error) in C:\OPSWAT\sf-core\wix-setup\OmsCustomAction\OmsCustomAction\OmsCustomAction.cs:line 263

=== Pre-bind state information ===
LOG: DisplayName = System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
 (Fully-specified)
LOG: Appbase = file:///C:/Users/eckkom/AppData/Local/Temp/MSI7CB0.tmp-
LOG: Initial PrivatePath = NULL
Calling assembly : System.Threading.Channels, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\eckkom\AppData\Local\Temp\MSI7CB0.tmp-\CustomAction.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: Attempting download of new URL file:///C:/Users/eckkom/AppData/Local/Temp/MSI7CB0.tmp-/System.Threading.Tasks.Extensions.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

更新Mar-24-2021:可能是Npgsql https://github.com/npgsql/npgsql/issues/2677的错误

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-03-24 11:49:53

显然,这可能是Npgsql的一个错误:https://github.com/npgsql/npgsql/issues/2677

但我最终找到了解决这个问题的办法。只需创建一个配置文件app.config或修改现有的.config文件,如下所示

代码语言:javascript
复制
<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.1" newVersion="5.0.0.1" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Threading.Channels" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

有关包的版本,请在项目参考中进行检查

票数 1
EN

Stack Overflow用户

发布于 2021-11-18 04:17:27

也有类似的问题。细节似乎很重要。除了上面的答案之外:

不知何故,Nuget创建了App.config文件,并将绑定重定向添加到Build Action设置为NoneApp.config,但有一个包含不同绑定重定向的CustomAction.config。在删除App.Config并将绑定重定向从它移动到CustomAction.config之后,它起作用了。值得一提的是,*.config文件的Build action应该设置为ContentCopy to output Directory - Do not Copy

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66757072

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档