user1689716 user1689716 - 1 month ago 22x
C# Question

Mkbundle Mono Assembly binding redirection

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

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.

The problem I am running into is with, 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"?>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" /></startup>


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


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

<bindingRedirect oldVersion="" newVersion="" />





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

enter image description here


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=, 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