Mkbundle Mono 程序集绑定重定向

2024-01-05

我有一个示例 .NET 应用程序,可以在 Windows 上正常运行,而我的 Ubuntu 环境则使用 Mono。

我正在尝试使用 Mkbundle 创建单个本机程序集,以便我可以使用 busybox 对它进行 docker 容器化,并保持较小的大小,而不是通常巨大的臃肿容器。

我遇到的问题是 Json.net,我认为这是由于 app.config 文件的程序集绑定重定向造成的,还有其他人遇到过这个问题吗?

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" /></startup>

  <runtime>

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

      <dependentAssembly>

        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />

        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />

      </dependentAssembly>

    </assemblyBinding>

  </runtime>

</configuration>

无论有没有 --static 都会产生以下错误


我解决这个问题的方法是指定 --nodeps 标志。

mkbundle --nodeps -o console OutsideSourcesAPI.exe *.dll

但是,当您运行它时,它可能会出现错误,例如...

The assembly mscorlib.dll was not found or could not be loaded.

or

Unhandled Exception: System.IO.FileNotFoundException: 
Could not load file or assembly 'System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies.

然后,您必须手动指定任何缺少的依赖项(我知道,有点臭)

mkbundle --nodeps -o console OutsideSourcesAPI.exe *.dll mscorlib.dll System.Xml.dll
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Mkbundle Mono 程序集绑定重定向 的相关文章

随机推荐