Mkbundle Mono程序集绑定重定向 [英] Mkbundle Mono Assembly binding redirection

查看:107
本文介绍了Mkbundle Mono程序集绑定重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a sample .NET application that runs fine on windows, and my Ubuntu environment using mono.

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

I am trying to use Mkbundle to create a single native assembly so I can docker containerize it using busybox and keep the size small instead of the usually huge bloated containers.

我遇到的问题是Json.net,我认为这是由于从app.config文件进行程序集绑定重定向,其他人遇到了这个问题?

The problem I am running into is with Json.net, I think its due to assembly binding redirection from the app.config file, anyone else ran into this?

<?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的情况下都会产生以下错误

And its producing the following error both with and without --static

推荐答案

我怎么解决的是指定--nodeps标志.

How I got around it was to specify the --nodeps flag.

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

但是,当您运行它时,它可能会给您类似...的错误

However, when you run it, it may give you errors like...

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

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.

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

You'll then have to specify any missing dependencies manually (I know, kinda of stinks)

mkbundle --nodeps -o console OutsideSourcesAPI.exe *.dll mscorlib.dll System.Xml.dll

这篇关于Mkbundle Mono程序集绑定重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆