Improve handling of missing Mono install on Linux/Mac
Pathoschild opened this issue ยท 3 comments
The content API fails when loading PNGs on Linux/Mac with an error like this:
A mod failed handling the TimeEvents.AfterDayStarted event:
StardewModdingAPI.Framework.Exceptions.SContentLoadException: The content manager failed loading content asset '/Users/amelieprecht/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS/Mods/TractorMod/assets/garage.png'. ---> System.InvalidOperationException: This image format is not supported ---> System.TypeInitializationException: The type initializer for 'System.Drawing.GDIPlus' threw an exception. ---> System.DllNotFoundException: libgdiplus.dylib
at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () <0x172eccd30 + 0x001d9> in :0
--- End of inner exception stack trace ---
at System.Drawing.Image.InitFromStream (System.IO.Stream stream) <0x172ecc8b0 + 0x00139> in :0
at System.Drawing.Image.LoadFromStream (System.IO.Stream stream, Boolean keepAlive) <0x172ecc720 + 0x00030> in :0
at System.Drawing.Image.FromStream (System.IO.Stream stream) <0x172ecc6f0 + 0x00016> in :0
at Microsoft.Xna.Framework.Graphics.Texture2D.PlatformFromStream (Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice, System.IO.Stream stream) <0x172ecc170 + 0x00040> in :0
at Microsoft.Xna.Framework.Graphics.Texture2D.FromStream (Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice, System.IO.Stream stream) <0x172ecc0a0 + 0x0002c> in :0
--- End of inner exception stack trace ---
at Microsoft.Xna.Framework.Graphics.Texture2D.FromStream (Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice, System.IO.Stream stream) <0x172ecc0a0 + 0x000b1> in :0
at StardewModdingAPI.Framework.SContentManager+<>c__DisplayClass28_01[T].<LoadFor>b__1 () <0x172ecb960 + 0x002f7> in <filename unknown>:0 at StardewModdingAPI.Framework.SContentManager.WithWriteLock[T] (System.Func
1 action) <0x11047df30 + 0x0003b> in :0
at StardewModdingAPI.Framework.SContentManager.LoadFor[T] (System.String assetName, Microsoft.Xna.Framework.Content.ContentManager instance) <0x11037ca50 + 0x002e8> in :0
--- End of inner exception stack trace ---
at Pathoschild.Stardew.TractorMod.TractorMod.GetTexture (System.String key) <0x172eca5b0 + 0x0011a> in :0
at Pathoschild.Stardew.TractorMod.TractorMod.GetBlueprint () <0x172ec8a40 + 0x000e6> in :0
at Pathoschild.Stardew.TractorMod.TractorMod.RestoreCustomData () <0x167b1fde0 + 0x000bb> in :0
at Pathoschild.Stardew.TractorMod.TractorMod.TimeEvents_AfterDayStarted (System.Object sender, System.EventArgs e) <0x16873ca60 + 0x00039> in :0
at StardewModdingAPI.Framework.InternalExtensions.SafelyRaisePlainEvent (IMonitor monitor, System.String name, IEnumerable`1 handlers, System.Object sender, System.EventArgs args) <0x1611a4770 + 0x001cc> in :0
Improve how this is handled, either by detecting and replacing that error or by requiring a Mono install before starting the game.
Fixed in develop
for the upcoming 2.3 release. SMAPI will now detect the error and show a more helpful message:
SContentLoadException: Failed loading content asset '<path>': couldn't find libgdiplus, which is needed to load mod images. Make sure Mono is installed and you're running the game through the normal launcher.
I am using macOS High Sierra. I already install mono using brew install mono
. I also installed libgdiplus using this command brew install glib cairo libexif libjpeg giflib libtiff autoconf libtool automake pkg-config
. I still got this error.
[ContentPatcher] Ignored Elle's Pig Replacement > Load Animals/BabyPig: error reading info. Technical details:
StardewModdingAPI.Framework.Exceptions.SContentLoadException: Failed loading content asset '/Users/piromsurang/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS/Mods/Elle's Pig Replacement [Spotted] [Pink and Brown]/assets/BabyPig.png': couldn't find libgdiplus, which is needed to load mod images. Make sure Mono is installed and you're running the game through the normal launcher.
at StardewModdingAPI.Framework.ContentPack.LoadAsset[T] (System.String key) <0x1593e4700 + 0x0005a> in :0
at ContentPatcher.Framework.AssetLoader.PreloadIfNeeded (IContentPack contentPack, System.String key) <0x1593d38d0 + 0x00122> in :0
at ContentPatcher.ModEntry.TryPrepareLocalAsset (IContentPack pack, System.String path, Pathoschild.Stardew.Common.Utilities.InvariantDictionary1 config, ContentPatcher.Framework.Conditions.ConditionDictionary conditions, System.String& error, ContentPatcher.Framework.Conditions.TokenString& tokenedPath, Boolean checkOnly) <0x1593d28d0 + 0x0039e> in <filename unknown>:0 at ContentPatcher.ModEntry.LoadPatch (IContentPack pack, ContentPatcher.Framework.ConfigModels.PatchConfig entry, Pathoschild.Stardew.Common.Utilities.InvariantDictionary
1 config, System.Action`1 logSkip) <0x1593ddf20 + 0x00d88> in :0
@piromsurang I suggest asking in the SMAPI support thread instead, there are more users there who may be able to help. Comments on an old closed ticket won't get much notice. :)