Unity-Technologies/UnityCsReference · error · Exception

Unknown dll type: {0}

Error message

Unknown dll type: {0}

What it means

Thrown by the default branch of a switch over the UnityEditorInternal.DllType enum that decides whether a DLL is a WinMD assembly. The switch only handles Unknown, Native, UnknownManaged, ManagedNET35, ManagedNET40, WinMDNative, WinMDNET40; any other enum value falls through to a generic Exception.

Source

Thrown at Editor/Mono/InternalEditorUtility.bindings.cs:1159

        [FreeFunction]
        internal static extern bool IsDotNetDll(string path);

        public static bool IsDotNet4Dll(string path)
        {
            var dllType = DetectDotNetDll(path);
            switch (dllType)
            {
                case UnityEditorInternal.DllType.Unknown:
                case UnityEditorInternal.DllType.Native:
                case UnityEditorInternal.DllType.UnknownManaged:
                case UnityEditorInternal.DllType.ManagedNET35:
                    return false;
                case UnityEditorInternal.DllType.ManagedNET40:
                case UnityEditorInternal.DllType.WinMDNative:
                case UnityEditorInternal.DllType.WinMDNET40:
                    return true;
                default:
                    throw new Exception(string.Format("Unknown dll type: {0}", dllType));
            }
        }

        internal static bool RunningUnderWindows8(bool orHigher = true)
        {
            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                OperatingSystem sys = System.Environment.OSVersion;
                int major = sys.Version.Major;
                int minor = sys.Version.Minor;
                // Window 8 is technically version 6.2
                if (orHigher)
                    return major > 6 || (major == 6 && minor >= 2);
                else
                    return major == 6 && minor == 2;
            }
            return false;
        }

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Update the switch to explicitly handle the new DllType value with the correct managed/native classification.
  2. Ensure the project and its packages target the same Unity version that defines the DllType values in use.
  3. Inspect the offending assembly's reported DllType to determine whether its metadata/importer settings are correct.

Example fix

// before
case UnityEditorInternal.DllType.WinMDNET40:
    return true;
default:
    throw new Exception(...);

// after
case UnityEditorInternal.DllType.WinMDNET40:
case UnityEditorInternal.DllType.NewType:
    return true;
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the project and packages target one Unity version so DllType values match the switch.

Try / catch

try { /* call site */ }
catch (Exception ex) when (ex.Message.StartsWith("Unknown dll type")) { Debug.LogError($"Unhandled DllType; check assembly metadata: {ex.Message}"); }

Prevention

When it happens

Trigger: A build or assembly-resolution path passes a DllType enum value added in a newer Unity version (or produced by a custom/unknown assembly type) that the switch was not updated to handle.

Common situations: Cross-version Unity builds where a new DllType was introduced. Custom precompiled assembly tooling that tags an assembly with an unexpected type. Corruption in assembly metadata producing an out-of-range enum value.

Related errors


AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13). Data as JSON: /api/errors/42177dc281685fe9. Report an issue: GitHub.