Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - Eluminate

#1
Hi all,
I have a question about using external dll's inside my mod (system.drawing in this instance).
The game gives an error when it's trying to call my constructor, saying it can't resolve the type "System.Drawing.Bitmap".
I tested this with a minimal mod, that just builds up a Bitmap and sends a message to the log.

Here is what I have so far (template from the cookiecutter)
Bitmaptest.cs
using System.Drawing;
using Verse;

namespace Bitmaptest
{
    [StaticConstructorOnStartup]
    public static class Bitmaptest
    {
        static Bitmaptest()
        {
            Log.Error("Working");

            var x = new Bitmap(1500, 1500);
        }
    }
}


This is the error that is thrown inside Rimworld as soon as the map is loaded in
Error in static constructor of Bitmaptest.Bitmaptest: System.TypeInitializationException: The type initializer for 'Bitmaptest.Bitmaptest' threw an exception. ---> System.TypeLoadException: Could not resolve type with token 01000013 (from typeref, class/assembly System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
   --- End of inner exception stack trace ---
  at (wrapper managed-to-native) System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(intptr)
  at System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor (System.RuntimeTypeHandle type) [0x0002a] in <eae584ce26bc40229c1b1aa476bfa589>:0
  at Verse.StaticConstructorOnStartupUtility.CallAll () [0x0001a] in <b64badbf3c3d41018b3ca5d3e8c77771>:0
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Verse.Log:Error (string)
Verse.StaticConstructorOnStartupUtility:CallAll ()
Verse.PlayDataLoader/<>c:<DoPlayLoad>b__4_3 ()
Verse.LongEventHandler:ExecuteToExecuteWhenFinished ()
Verse.LongEventHandler:UpdateCurrentAsynchronousEvent ()
Verse.LongEventHandler:LongEventsUpdate (bool&)
Verse.Root:Update ()
Verse.Root_Entry:Update ()


This is my solution, showing the info for System.Drawing



I have no clue what is causing this error. I tried to copy the dll inside the mod's assembly folder and to copy it inside the rimworld managed folder, but no luck.
It looks like it can't find the System.Drawing library or that there is a mismatch between the found version and the expected one?
Can someone tell me what i'm missing here?
Is it possible to use an external library like System.Drawing?

Thanks you in advance,
Eluminate