Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Exceptions on Assembly.LoadTypes for assembly "Accessibility" (2018.3.9)

Discussion in 'Experimental Scripting Previews' started by Baste, Mar 22, 2019.

  1. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,336
    I'm suddenly getting some exceptions from reflection calls that used to work fine, and before I report a bug, I'm wondering if someone has any idea about how to track down what's going on.

    A few of our editor tools and our savegame serializer does this:

    Code (csharp):
    1. var allTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(assembly => assembly.GetTypes());
    2. // do something with all types
    This worked without a hitch up to 2018.3.8, but has started throwing exceptions now. Adding some try-catch:

    Code (csharp):
    1.  //foreach assembly in AppDomain.CurrentDomain.GetAssemblies()
    2. try {
    3.     types = assembly.GetTypes();
    4. }
    5. catch (ReflectionTypeLoadException rtle) {
    6.     if (!hasErroredThisReload) {
    7.         Debug.LogError($"Can't load types from assembly {assembly.GetName().Name}. Exceptions follow");
    8.         Debug.LogException(rtle);
    9.         foreach (var exception in rtle.LoaderExceptions) {
    10.             Debug.LogException(exception);
    11.         }
    12.         hasErroredThisReload = true;
    13.     }
    14.  
    15.     continue;
    16. }
    Output:

    Code (csharp):
    1.  
    2. Can't load types from assembly Accessibility. Exceptions follow
    3. UnityEngine.Debug:LogError(Object)
    4. <GetTypesFrom>d__2:MoveNext() (at Assets/Scripts/ExtensionMethods/AssemblyHelper.cs:22)
    5. ...
    6.  
    7. ReflectionTypeLoadException: Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown.
    8. System.Reflection.Assembly.GetTypes () (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
    9. AssemblyHelper+<GetTypesFrom>d__2.MoveNext ()
    10. ...
    11.  
    12. TypeLoadException: Could not set up field 'u' due to: Missing field layout info for hInproc assembly:C:\Program Files\Unity\Hub\Editor\2018.3.9f1\Editor\Data\MonoBleedingEdge\lib\mono\unityjit\Accessibility.dll type:__MIDL_IWinTypes_0009 member:(null) signature:<none>
    13. UnityEngine.Debug:LogException(Exception)
    14. <GetTypesFrom>d__2:MoveNext() (at Assets/Scripts/ExtensionMethods/AssemblyHelper.cs:25)
    15. ...
    16.  
    17. TypeLoadException: Missing field layout info for hInproc
    18. UnityEngine.Debug:LogException(Exception)
    19. <GetTypesFrom>d__2:MoveNext() (at Assets/Scripts/ExtensionMethods/AssemblyHelper.cs:25)
    20. ...
    21.  
    So it seems like there's errors when loading something from the .NET built-in Accessibility framework. Googling "hInproc" gets me here.

    This doesn't happen in a blank project, but I can't figure out how to make a repro case, as I have no idea why Accessibility is even referenced. If I do a text search through the project, I only get references to UnityEngine.AccessibilityModule in .csproj files, and as far as I can tell, that doesn't reference Accessibility.

    Anyone have any idea what's going on here? I'd love to create a repro, but I don't even know where to start stripping out things.
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
  3. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,336
    Thanks for the quick reply! I obviously didn't try to google hard enough, sorry about that.
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    No worries, this was just fixed yesterday.
     
  5. joaobsneto

    joaobsneto

    Joined:
    Dec 10, 2009
    Posts:
    152
    I updated to 2018.3.11 and I still get the same error:
    Code (CSharp):
    1. TypeLoadException: Could not set up field 'u' due to: Missing field layout info for hInproc assembly:C:\Program Files\Unity\Hub\Editor\2018.3.11f1\Editor\Data\MonoBleedingEdge\lib\mono\unityjit\Accessibility.dll type:__MIDL_IWinTypes_0009 member:(null) signature:<none>
     
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Unfortunately the fix slipped to 2018.3.12, it was not in 2018.3.11.
     
    joaobsneto likes this.