[Mono-dev] mkbundle null reference exception with --deps option

David Curylo curylod at asme.org
Thu Oct 26 03:03:18 UTC 2017


I found my mkbundle jobs started failing a couple months ago, I believe with a switch to mono 5.2.0.224, with this error:

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at MakeBundle.QueueAssembly (System.Collections.Generic.List`1[T] files, System.String codebase) [0x000bc] in <1eb347299adf445aac66783f3da9ec85>:0 
  at MakeBundle.Main (System.String[] args) [0x00d5f] in <1eb347299adf445aac66783f3da9ec85>:0 

I was hoping this would be fixed with 5.4.0.201, but it still seems to fail.  I started digging and it seems that having the --deps option can cause this exception if certain assemblies are referenced.  I haven’t figured out which assemblies, maybe facades?  A simple “hello world” with very few dependencies works fine, but something with additional framework libraries hits this issue, so I have a “hello world” with the Suave web framework, which includes more of the framework in the bundle.

I can reproduce the issue with the following Dockerfile, which will throw the exception at the point it tries to make the bundle.  Drop off the --deps option and it works fine (albeit I have to be sure to include all assemblies or there are runtime errors).  Any idea what is happening with --deps here?

FROM mono:5.4.0.201 as builder
RUN mkdir /src
RUN echo 'open Suave\n\
[<EntryPoint>]\n\
let main argv =\n\
    startWebServer defaultConfig (Successful.OK "Hello World!")\n\
    0\n\
' > /src/hello.fs
RUN echo '<Project Sdk="Microsoft.NET.Sdk">\n\
  <PropertyGroup>\n\
    <OutputType>Exe</OutputType>\n\
    <TargetFramework>net462</TargetFramework>\n\
  </PropertyGroup>\n\
  <ItemGroup>\n\
    <Compile Include="hello.fs" />\n\
  </ItemGroup>\n\
  <ItemGroup>\n\
    <PackageReference Include="suave" Version="2.2.1" />\n\
  </ItemGroup>\n\
</Project>' > /src/hello.fsproj
WORKDIR src
RUN msbuild /t:restore
RUN msbuild /t:build
RUN apt-get update && apt-get install -y gcc
RUN cd bin/Debug/net462 && mkbundle --deps --static --config /etc/mono/config -L /usr/lib/mono/4.5 -o hello hello.exe *.dll /usr/lib/mono/4.5/mscorlib.dll /usr/lib/mono/4.5/System.dll



More information about the Mono-devel-list mailing list