Search Unity

DllNotFoundException for native DLL in 2019.x

Discussion in 'Scripting' started by FlaSh-G, Oct 17, 2019.

  1. FlaSh-G

    FlaSh-G

    Joined:
    Apr 21, 2010
    Posts:
    212
    Hi there,

    I just spent three days working on a weird issue, and since I found no resources at all on this, I just wanted to leave my findings here.

    I was using a native DLL in my project, like this:
    Code (CSharp):
    1. #if UNITY_IPHONE || UNITY_XBOX360
    2.         private const string dll = "__Internal";
    3. #else
    4.         private const string dll = "name-of-the.dll";
    5. #endif
    followed by one or more
    Code (CSharp):
    1. [DllImport(dll)]
    2. static extern void SomeExternMethod();
    This is in accordance to the manual page about native DLLs with the addition of XBox360 as a platform that also has one big "__Internal" dll. To be honest, I don't remember where I found that additional bit of information.

    This code worked fine for years now, but starting with Unity 2019, I got DllNotFoundExceptions with every method call. Since the (linked) manual page doesn't mention anything about this, it took me some while to find out that i needed to switch to "__Internal" entirely, so my new code looks like this:
    Code (CSharp):
    1. #if UNITY_2019_1_OR_NEWER || UNITY_IPHONE || UNITY_XBOX360
    2.         private const string dll = "__Internal";
    3. #else
    4.         private const string dll = "name-of-the.dll";
    5. #endif
    So, apart from maybe helping someone else with that issue, I was wondering if anyone had an idea whether this is
    • a bug that existed for a whole year without being discovered (as I said, I found nothing on this for days),
    • some newly available Mono setting or something that I'd have to change, or
    • the documentation not having been updated properly.
    If noone slaps me on the forehead about some weird mistake I made, I'll report this as a bug within the next few days. Until then, maybe this little fix helps someone searching their butt off ;)
     
    Kurt-Dekker and DwinTeimlon like this.
  2. FlaSh-G

    FlaSh-G

    Joined:
    Apr 21, 2010
    Posts:
    212
    The bug is reported, I'll relay updates about it to this thread.