Mono ''netstandard" error

I have a xamarin app that I want to make a snap for.

The app must be run with mono app.exe

The snapcraft.yaml looks like this

name: myapp
base: core18
version: "6.4.27"
summary: aa bb ...
description: |
  nnn aaa bss

    source: snap/local/myapp
    plugin: nil
    override-build: |
      cp -rf ./* $SNAPCRAFT_PART_INSTALL/
      - mono-complete
      - gtk-sharp2

    command: mono $SNAP/app.exe

snapcraft completes and makes a snap.

But when I install the snap and run

snap run myapp

I get the error message

Unhandled Exception:
 System.IPreformatted textO.FileNotFoundException: Could not load file or assembly or one of its dependencies.
 File name: 'netstandard, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'

If I run

mono app.exe

outside snap it works fine.

Can that problem be solved ?

– Eigil

Mono has a few environment variables that help make it portable, namely




You can make use of an environment stanza in your snapcraft.yaml to help set these, e.g:

  MONO_CONFIG: "$SNAP/etc/mono/config"
  MONO_GAC_PREFIX: "$SNAP/usr/lib/mono/gac"
  MONO_PATH: *ThisOneIsUniqueToYourSnapAndRequiresManualWork*

This comes from my work on the Pinta snap, which uses a newer upstream Mono version than provided in the Ubuntu repositories but I presume would likely work the same. In the dev builds which swapped to .NET 5, I haven’t had to do any special work with environment variables, but whether that’s a result of Mono -> .NET or changes in the Pinta build environment I couldn’t tell you.

Regardless, if you search for all the locations of the dependent DLL in the snap you’d be able to specify them similar to my real world example like so:

MONO_PATH: "$SNAP/usr/lib/cli/atk-sharp-2.0:$SNAP/usr/lib/cli/gdk-sharp-2.0:$SNAP/usr/lib/cli/glib-sharp-2.0:$SNAP/usr/lib/cli/gtk-dotnet-2.0:$SNAP/usr/lib/cli/gtk-sharp-2.0:$SNAP/usr/lib/cli/Mono.Addins-0.2:$SNAP/usr/lib/cli/Mono.Addins.CecilReflector-0.2:$SNAP/usr/lib/cli/Mono.Addins.Gui-0.2:$SNAP/usr/lib/cli/Mono.Addins.Setup-0.2:$SNAP/usr/lib/cli/pango-sharp-2.0"

I also happen to have this layout defined, I can’t recall as to why, but presumably it’s relevant to snapping Mono applications.

    bind: $SNAP/usr/lib/cli


Hi @ ekrogh.

Have you succeeded creating/running your Xamarin app over Snap?

If so, would you share the snap details? I’m trying to achieve the same.