Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

System.Xml.Serialization.XmlSerializer gives kernel32.dll error with .NET 4.6

Discussion in 'Windows' started by Mogurito, Apr 10, 2017.

  1. Mogurito

    Mogurito

    Joined:
    Sep 21, 2015
    Posts:
    11
    Hi guys, i got this error:
    DllNotFoundException: Unable to load DLL 'kernel32.dll': The specified module could not be found.
    at Microsoft.Win32.UnsafeNativeMethods.GetModuleHandle (System.String moduleName) [0x00000] in <00000000000000000000000000000000>:0
    at Microsoft.Win32.UnsafeNativeMethods.DoesWin32MethodExist (System.String moduleName, System.String methodName) [0x00000] in <00000000000000000000000000000000>:0
    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
    at System.Xml.Serialization.XmlSerializer..ctor (System.Type type) [0x00000] in <00000000000000000000000000000000>:0
    at LocalizationManager.Awakee () [0x00000] in <00000000000000000000000000000000>:0
    at LocalizationManager.Awake () [0x00000] in <00000000000000000000000000000000>:0

    when using this namespace
    System.Xml.Serialization.XmlSerializer

    and building with IL2CPP and .NET 4.6

    So is XmlSerializer not supported when building with .NET 4.6?
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    It's a known issue - we are looking into potential fixes. It's tracked by case 887128.

    But yeah, unfortunately it does not work today.
     
  3. Mogurito

    Mogurito

    Joined:
    Sep 21, 2015
    Posts:
    11
  4. treasa-foolery

    treasa-foolery

    Joined:
    Oct 20, 2014
    Posts:
    6
    Hey guys, I'm still having this issue in 2018.2.4f1. Is there a specific version I need to be on for the fix?
     
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    The workaround today is to switch to .NET Standard 2.0 (NOT .NET 2.0) profile. The fix for .NET 4.6 profile is coming to Unity 2018.3.
     
  6. nilsubimax

    nilsubimax

    Joined:
    Apr 3, 2017
    Posts:
    17
    Hey, still running into this with 2018.3.b6 when using .NET 4.6 profile. The linked issue tracker item shows the issue as been resolved, but it has only been fixed for the .NET Standard 2.0 set.

    Is there a fix for .NET 4.6 planned for 2018.3?
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    This should be working on .NET 4.6 profile in 2018.3. Let me follow up on it.

    In the meantime, what scripting runtime version is set in the editor to on your project?
     
  8. nilsubimax

    nilsubimax

    Joined:
    Apr 3, 2017
    Posts:
    17
    We're having the following configuration:
    • Scripting Backend: IL2CPP
    • Scripting Runtime: .NET 4.x Equivalent
    • API level: .NET 4.x
    We're building for Microsoft HoloLens with it, using the newest Release of the MRTK. We also use a lot of other thirdparty libraries like RestSharp.Portable, Newtonsoft.Json, Serilog etc - essentially the whole backend of a complex business application.

    We found that we're able to compile with .NET Standard 2.0 as well, so besides some smaller things we had to take out we have a workaround available. However having it solved for .NET 4.6 as well would be better to have.

    We're using 2018.3.0b6 right now, but will update to the newest beta version of Unity soon.
     
  9. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    I can confirm the fix for .NET 4.6 profile landed to 2018.3.0b8 which is about to be released.
     
  10. Kastar-Troy

    Kastar-Troy

    Joined:
    Jul 18, 2012
    Posts:
    29
    I'm still getting this same error in 2019.3. How is this possible so many years later...
     
  11. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    Are you sure you're facing the same issue? It was fixed a year ago.
     
  12. tarnumius

    tarnumius

    Joined:
    Feb 16, 2018
    Posts:
    7
    Hello.

    Receive same warning on Android

    2020.04.29 13:35:23.481 26607 26641 Warn Unity : Plugins: Couldn't open kernel32, error: dlopen failed library "kernel32" not found
    2020.04.29 13:35:23.481 26607 26641 Warn Unity Microsoft.Win32.<>c:<.cctor>b__9_0()
    2020.04.29 13:35:23.481 26607 26641 Warn Unity System.Lazy`1:CreateValue()
    2020.04.29 13:35:23.481 26607 26641 Warn Unity System.Lazy`1:LazyInitValue()
    2020.04.29 13:35:23.481 26607 26641 Warn Unity System.Lazy`1:get_Value()
    2020.04.29 13:35:23.481 26607 26641 Warn Unity System.Xml.Serialization.TempAssembly:LoadGeneratedAssembly(Type, String, XmlSerializerImplementation&)
    2020.04.29 13:35:23.481 26607 26641 Warn Unity System.Xml.Serialization.XmlSerializer:.ctor(Type, String)
    2020.04.29 13:35:23.481 26607 26641 Warn Unity System.Xml.Serialization.XmlSerializer:.ctor(Type)

    The warning occurs sometimes and generally does not interfere with the operation, since XML serialization continues to work.