Search Unity

[UWP] Unable to load DLL 'kernel32.dll': The specified module could not be found.

Discussion in 'Windows' started by dwilson_visiblebody, Nov 29, 2018.

  1. dwilson_visiblebody

    dwilson_visiblebody

    Joined:
    Oct 21, 2016
    Posts:
    4
    Hello,

    I am creating a UWP app that is just targeting PC and attempting to use the System.Xml.Serialization namespace to serialize and deserialize some content. Whenever I attempt to make a call to this namespace, specifically creating a new serializer, I get the following error:

    Unable to load DLL 'kernel32.dll': The specified module could not be found.
    at Microsoft.Win32.UnsafeNativeMethods._IsPackagedProcess () [0x00000] in <00000000000000000000000000000000>:0
    at System.Func`1[TResult].Invoke () [0x00000] in <00000000000000000000000000000000>:0
    at System.Lazy`1[T].CreateValue () [0x00000] in <00000000000000000000000000000000>:0
    at System.Lazy`1[T].LazyInitValue () [0x00000] in <00000000000000000000000000000000>:0
    at System.Lazy`1[T].get_Value () [0x00000] in <00000000000000000000000000000000>:0
    at System.Xml.Serialization.TempAssembly.LoadGeneratedAssembly (System.Type type, System.String defaultNamespace, System.Xml.Serialization.XmlSerializerImplementation& contract) [0x00000] in <00000000000000000000000000000000>:0
    at System.Xml.Serialization.XmlSerializer..ctor (System.Type type, System.String defaultNamespace) [0x00000] in <00000000000000000000000000000000>:0

    This was not a problem when using the .NET scripting backend a year ago, but it has since been marked deprecated and we have switched to using the IL2CPP scripting backend. As for a few of my other settings, I am using .NET 4.x Equivalent for the Scripting Runtime Version and .NET 4.x as my API Compatibility Level. The version of Unity I am using is 2018.2.11f1.

    I am not sure if this is something wrong with the IL2CPP build pipeline or if I am doing something incorrect when building the project. Thank you in advance for any help!
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,436
    This is a bug in IL2CPP. It only happens in .NET 4.x API compatibility level - you could work around it if you switched to .NET Standard 2.0 (note: not .NET 2.0 or .NET 2.0 subset).

    It is fixed in 2018.3.
     
  3. dwilson_visiblebody

    dwilson_visiblebody

    Joined:
    Oct 21, 2016
    Posts:
    4
    Thank you for your help and quick reply!
     
  4. SATAN3

    SATAN3

    Joined:
    Mar 20, 2019
    Posts:
    2
    Not in the same context but I had the same error "Unable to find kernel32.dll" using Unity 2017, .NET 4.X and Mono.

    Switch to Unity 2018.3 fixed it so anyways it worth the try.
     
  5. dwilson_visiblebody

    dwilson_visiblebody

    Joined:
    Oct 21, 2016
    Posts:
    4
    Thank you! Appreciate all of the responses!
     
  6. Lesha-VH

    Lesha-VH

    Joined:
    Jul 3, 2012
    Posts:
    77
    I got the same run-time error as in first post.

    Unity 2017.4.30f1, ILL2CPP, API compatibility level: .NET 4.6

    How to fix it using Unity 2017.4 LTS?
    As I understand I can not use .NET Standard 2.0 in 2017 LTS
    Can anyone help? Solution to use Unity 2018 require some work...

    If I switch to API compatibility level: .NET 2.0 or .NET 2.0 subset the project failed to build.

    As I see most easy way - get rid of XML serialization)
     
    Last edited: Sep 14, 2019 at 7:39 AM