{"record":{"id":"9e6be2f4006de448","repo":"Unity-Technologies/UnityCsReference","slug":"il2cpp-is-not-supported-for-this-platform","errorCode":null,"errorMessage":"IL2CPP is not supported for this platform.","messagePattern":"IL2CPP is not supported for this platform\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/IScriptingPlatformProperties.cs","lineNumber":19,"sourceCode":"// Unity C# reference source\n// Copyright (c) Unity Technologies. For terms of use, see\n// https://unity3d.com/legal/licenses/Unity_Reference_Only_License\n\nusing System;\n\nnamespace UnityEditor;\n\ninternal interface IScriptingPlatformProperties : IPlatformProperties\n{\n    /// <summary>\n    /// Points to the CoreCLR BCL Directory\n    /// </summary>\n    public string CoreCLRBCLDirectory => throw new NotSupportedException(\"CoreCLR is not supported for this platform.\");\n\n    /// <summary>\n    /// Points to the IL2CPP directory\n    /// </summary>\n    public string IL2CPPBCLDirectory => throw new NotSupportedException(\"IL2CPP is not supported for this platform.\");\n\n}\n","sourceCodeStart":1,"sourceCodeEnd":22,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/IScriptingPlatformProperties.cs#L1-L22","documentation":"This is a default interface member on IScriptingPlatformProperties. The IL2CPPBCLDirectory getter unconditionally throws NotSupportedException because the implementing platform does not provide a CoreCLR/IL2CPP Base Class Library directory. Platforms that actually support IL2CPP are expected to override this property with a real path; the throwing member is the fallback contract for platforms that never will.","triggerScenarios":"Accessing IScriptingPlatformProperties.IL2CPPBCLDirectory (or CoreCLRBCLDirectory) on a platform implementation that did not override it. This happens when editor code queries the scripting backend BCL directory for a platform whose IPlatformProperties/IScriptingPlatformProperties implementation leaves the default member in place.","commonSituations":"Adding or using a custom/lesser platform module (e.g. a stripped or in-house target) that implements IPlatformProperties but omits the IL2CPP BCL directory override. Switching a project to a platform that intentionally only supports Mono. Editor tooling that iterates all platforms and assumes every one returns a BCL directory.","solutions":["If you own the platform implementation, override IL2CPPBCLDirectory in your IScriptingPlatformProperties implementer to return the real IL2CPP BCL path.","Before accessing, guard with a check that the platform supports IL2CPP (e.g. via BuildPipeline/PlatformSupports scripting backend query) so the property is never hit for unsupported platforms.","If you only need the CoreCLR BCL, use CoreCLRBCLDirectory instead — but note it has the same throwing default and must also be overridden.","Report a bug if a built-in/shipped platform reaches this throw, since shipped platforms are expected to override the member."],"exampleFix":"// before\nstring dir = props.IL2CPPBCLDirectory; // throws for unsupported platform\n\n// after\nstring dir = supportsIl2cpp ? props.IL2CPPBCLDirectory : string.Empty;","handlingStrategy":"validation","validationCode":"// before touching the property, confirm the platform supports IL2CPP\nvar props = platform as IScriptingPlatformProperties;\nstring dir = string.Empty;\n// Prefer a scripting-backend support check; only read if supported\nif (BuildPipeline.IsFeatureSupported(BuildFeatures.Il2cpp, platformTarget))\n    dir = props.IL2CPPBCLDirectory;","typeGuard":"// narrow to platforms known to override the member\nstatic bool SupportsIl2cppBcl(IScriptingPlatformProperties p)\n    => p.GetType().GetMethod(\"get_IL2CPPBCLDirectory\")?.DeclaringType == p.GetType();","tryCatchPattern":"try { dir = props.IL2CPPBCLDirectory; }\ncatch (NotSupportedException) { dir = string.Empty; /* platform has no IL2CPP BCL */ }","preventionTips":["Treat IL2CPPBCLDirectory/CoreCLRBCLDirectory as opt-in: only read them for platforms you know override them.","When adding a custom platform, override both BCL directory members or document that IL2CPP is unsupported.","Gate platform-iteration code on scripting-backend support rather than blindly reading the property for every platform."],"tags":["il2cpp","platform","scripting-backend","notsupported","unity-editor"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}