+1
Fixed

Errors from Peek when importing NG Tools Pro Project 2019.2

WakeArray 2 months ago updated by Lazlo Bonin (Lead Developer) 1 month ago 9

Error:
TypeLoadException: Could not resolve type with token 01000085 (from typeref, class/assembly UnityEngine.AssemblyIsEditorAssembly, UnityEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)
System.MonoCustomAttrs.IsDefined (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inherit) (at <599589bf4ce248909b8a14cbe4a2034e>:0)
System.Reflection.Assembly.IsDefined (System.Type attributeType, System.Boolean inherit) (at <599589bf4ce248909b8a14cbe4a2034e>:0)
System.Attribute.IsDefined (System.Reflection.Assembly element, System.Type attributeType, System.Boolean inherit) (at <599589bf4ce248909b8a14cbe4a2034e>:0)
System.Attribute.IsDefined (System.Reflection.Assembly element, System.Type attributeType) (at <599589bf4ce248909b8a14cbe4a2034e>:0)
Ludiq.PeekCore.Codebase.IsEditorAssembly (System.Reflection.Assembly assembly) (at Assets/Ludiq/Ludiq.PeekCore/Editor/Reflection/Codebase.cs:229)
Ludiq.PeekCore.Codebase.IsEditorDependentAssembly (System.Reflection.Assembly assembly) (at Assets/Ludiq/Ludiq.PeekCore/Editor/Reflection/Codebase.cs:247)
Ludiq.PeekCore.Codebase.IsRuntimeAssembly (System.Reflection.Assembly assembly) (at Assets/Ludiq/Ludiq.PeekCore/Editor/Reflection/Codebase.cs:242)
Ludiq.PeekCore.Codebase..cctor () (at Assets/Ludiq/Ludiq.PeekCore/Editor/Reflection/Codebase.cs:40)
Rethrow as TypeInitializationException: The type initializer for 'Ludiq.PeekCore.Codebase' threw an exception.
Ludiq.PeekCore.PluginContainer.Initialize () (at Assets/Ludiq/Ludiq.PeekCore/Editor/Plugins/PluginContainer.cs:110)
Ludiq.PeekCore.PluginContainer+<>c.<.cctor>b__0_0 () (at Assets/Ludiq/Ludiq.PeekCore/Editor/Plugins/PluginContainer.cs:31)
UnityEditor.EditorApplication.Internal_CallDelayFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:312)

This error happens every time I try to import Peek into a project with NG Tools Pro or import NG Tools Pro into a project that had Peek.

I acquired both Peek and NG Tools at the same time over the Cyber Monday sale and haven't fully had time to try either out yet, but the error prevents Peek from working in any capacity while NG Tools Pro is installed.

Unity Version:
2019.2.10f1 && 2019.2.14f1
Peek Version:
1.1.5
GOOD, I'M SATISFIED

That was a super fast fix guys, thanks so much. :)

Satisfaction mark by WakeArray 1 month ago
+1
A different error:
System.TypeInitializationException: The type initializer for 'Ludiq.PeekCore.Codebase' threw an exception. ---> System.TypeLoadException: Could not resolve type with token 01000085 (from typeref, class/assembly UnityEngine.AssemblyIsEditorAssembly, UnityEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null) at (wrapper managed-to-native) System.MonoCustomAttrs.IsDefinedInternal(System.Reflection.ICustomAttributeProvider,System.Type) at System.MonoCustomAttrs.IsDefined (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inherit) [0x00027] in <599589bf4ce248909b8a14cbe4a2034e>:0 at System.Reflection.Assembly.IsDefined (System.Type attributeType, System.Boolean inherit) [0x00000] in <599589bf4ce248909b8a14cbe4a2034e>:0 at System.Attribute.IsDefined (System.Reflection.Assembly element, System.Type attributeType, System.Boolean inherit) [0x0005c] in <599589bf4ce248909b8a14cbe4a2034e>:0 at System.Attribute.IsDefined (System.Reflection.Assembly element, System.Type attributeType) [0x00000] in <599589bf4ce248909b8a14cbe4a2034e>:0 at Ludiq.PeekCore.Codebase.IsEditorAssembly (System.Reflection.Assembly assembly) [0x00001] in C:\Users\Wake\Desktop\Unity\AI Test Project\Assets\Ludiq\Ludiq.PeekCore\Editor\Reflection\Codebase.cs:229 at Ludiq.PeekCore.Codebase.IsEditorDependentAssembly (System.Reflection.Assembly assembly) [0x00001] in C:\Users\Wake\Desktop\Unity\AI Test Project\Assets\Ludiq\Ludiq.PeekCore\Editor\Reflection\Codebase.cs:247 at Ludiq.PeekCore.Codebase.IsRuntimeAssembly (System.Reflection.Assembly assembly) [0x00001] in C:\Users\Wake\Desktop\Unity\AI Test Project\Assets\Ludiq\Ludiq.PeekCore\Editor\Reflection\Codebase.cs:242 at Ludiq.PeekCore.Codebase..cctor () [0x000c5] in C:\Users\Wake\Desktop\Unity\AI Test Project\Assets\Ludiq\Ludiq.PeekCore\Editor\Reflection\Codebase.cs:40 --- End of inner exception stack trace --- at Ludiq.PeekCore.PluginContainer.Initialize () [0x00054] in C:\Users\Wake\Desktop\Unity\AI Test Project\Assets\Ludiq\Ludiq.PeekCore\Editor\Plugins\PluginContainer.cs:110 at Ludiq.PeekCore.PluginContainer..cctor () [0x00015] in C:\Users\Wake\Desktop\Unity\AI Test Project\Assets\Ludiq\Ludiq.PeekCore\Editor\Plugins\PluginContainer.cs:21 UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes(Type[]) (at C:/buildslave/unity/build/Editor/Mono/EditorAssemblies.cs:112)
+1

Same here, and it's a biggie. The 2 tools are clearly sharing some functionality, but they shouldn't render each other unusable.
Unsurprisingly, it also happens on 2019.2.15

+1

TypeLoadException: Could not resolve type with token 01000084 (from typeref, class/assembly UnityEngine.AssemblyIsEditorAssembly, UnityEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)

System.MonoCustomAttrs.IsDefined (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inherit) (at <567df3e0919241ba98db88bec4c6696f>:0)

System.Reflection.Assembly.IsDefined (System.Type attributeType, System.Boolean inherit) (at <567df3e0919241ba98db88bec4c6696f>:0)

System.Attribute.IsDefined (System.Reflection.Assembly element, System.Type attributeType, System.Boolean inherit) (at <567df3e0919241ba98db88bec4c6696f>:0)

System.Attribute.IsDefined (System.Reflection.Assembly element, System.Type attributeType) (at <567df3e0919241ba98db88bec4c6696f>:0)

Ludiq.PeekCore.Codebase.IsEditorAssembly (System.Reflection.Assembly assembly) (at Assets/Ludiq/Ludiq.PeekCore/Editor/Reflection/Codebase.cs:229)

Ludiq.PeekCore.Codebase.IsEditorDependentAssembly (System.Reflection.Assembly assembly) (at Assets/Ludiq/Ludiq.PeekCore/Editor/Reflection/Codebase.cs:247)

Ludiq.PeekCore.Codebase.IsRuntimeAssembly (System.Reflection.Assembly assembly) (at Assets/Ludiq/Ludiq.PeekCore/Editor/Reflection/Codebase.cs:242)

Ludiq.PeekCore.Codebase..cctor () (at Assets/Ludiq/Ludiq.PeekCore/Editor/Reflection/Codebase.cs:40)

Rethrow as TypeInitializationException: The type initializer for 'Ludiq.PeekCore.Codebase' threw an exception.

Ludiq.PeekCore.PluginContainer.Initialize () (at Assets/Ludiq/Ludiq.PeekCore/Editor/Plugins/PluginContainer.cs:110)

Ludiq.PeekCore.PluginContainer+<>c.<.cctor>b__0_0 () (at Assets/Ludiq/Ludiq.PeekCore/Editor/Plugins/PluginContainer.cs:31)

UnityEditor.EditorApplication.Internal_CallDelayFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:312)

+1

Thank you Andras for pointing me this bug report.


I will get in touch with Ludiq before going forward.

+1

File: 'Assets/Ludiq/Ludiq.PeekCore/Editor/Reflection/Codebase.cs'

Line: 227

Method: 'IsEditorAssembly'

Calling IsDefined() on an assembly which can throw a type load exception when the assembly is heavily obfuscated.

Suggested patch:

private static bool IsEditorAssembly(Assembly assembly)
{
    try
    {
        if (Attribute.IsDefined(assembly, typeof(AssemblyIsEditorAssembly)))
        {
            return true;
        }

        return IsEditorAssembly(assembly.GetName());
    }
    catch (Exception ex)
    {
        Debug.LogWarning($"Failed to define if assembly '{assembly}' is editor.\n{ex}");
    }

    return false;
}
+1
Escalated

Hi Michaël, thanks for stepping in and investigating this.

I'll look into implementing that fallback (and also more generally recovering from assembly load failures in the plugin container).

+1

As a side-note, I investigated a little more into this issue and discovered the culprit.

The reason behind this exception is not the heaviness of the obfuscation, but the corruption of the assembly.

API Updater can incorrectly patch an assembly therefore corrupting it.

The bug has been reported already.

+2
Fixed (Unreleased)

Hi Michaël, WakeArray, Andras,

I added a try-catch clause to catch the error and lets Peek load for v.1.1.6.

However, there will be a warning in the console about the assembly that failed to get analyzed, because the user should be warned that something went wrong. Hopefully Unity fixes the bug in the API updater patching so that NG assemblies no longer get corrupted in the future.