{"record":{"id":"cacccca7208ed992","repo":"stride3d/stride","slug":"applicationdatasubdirectory-cannot-be-modified-after-the","errorCode":null,"errorMessage":"ApplicationDataSubDirectory cannot be modified after the VirtualFileSystem has been initialized.","messagePattern":"ApplicationDataSubDirectory cannot be modified after the VirtualFileSystem has been initialized\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core/PlatformFolders.cs","lineNumber":58,"sourceCode":"\n    /// <summary>\n    /// The application data directory, where data is deployed.\n    /// It could be read-only on some platforms.\n    /// </summary>\n    public static readonly string ApplicationDataDirectory = GetApplicationDataDirectory();\n\n    /// <summary>\n    /// The (optional) application data subdirectory. If not null or empty, /data will be mounted on <see cref=\"ApplicationDataDirectory\"/>/<see cref=\"ApplicationDataSubDirectory\"/>\n    /// </summary>\n    /// <remarks>This property should not be written after the VirtualFileSystem static initialization. If so, an InvalidOperationExeception will be thrown.</remarks>\n    public static string ApplicationDataSubDirectory\n    {\n        get { return applicationDataSubDirectory; }\n\n        set\n        {\n            if (IsVirtualFileSystemInitialized)\n                throw new InvalidOperationException(\"ApplicationDataSubDirectory cannot be modified after the VirtualFileSystem has been initialized.\");\n\n            applicationDataSubDirectory = value;\n        }\n    }\n\n    /// <summary>\n    /// The application directory, where assemblies are deployed.\n    /// It could be read-only on some platforms.\n    /// </summary>\n    public static readonly string ApplicationBinaryDirectory = GetApplicationBinaryDirectory();\n\n    /// <summary>\n    /// Get the path to the application executable.\n    /// </summary>\n    /// <remarks>Might be null if start executable is unknown.</remarks>\n    public static readonly string? ApplicationExecutablePath = GetApplicationExecutablePath();\n\n    private static string applicationDataSubDirectory = string.Empty;","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core/PlatformFolders.cs#L40-L76","documentation":"PlatformFolders.ApplicationDataSubDirectory configures the subfolder under the user's application-data directory that Stride's VirtualFileSystem mounts at startup. Once the VFS is initialized the mount points are baked in, so the setter throws InvalidOperationException if changed afterwards.","triggerScenarios":"Setting PlatformFolders.ApplicationDataSubDirectory after anything has triggered VFS initialization (e.g. after creating a Game, database, or touching virtual file system paths).","commonSituations":"Assigning the property in game-loop or service-constructor code instead of the very start of Main; a static initializer elsewhere touching the file system first and reordering startup.","solutions":["Set ApplicationDataSubDirectory as the first thing in Main/Program before constructing any Stride runtime objects.","Restructure code so the value comes from configuration read before engine initialization.","If it must change at runtime, restart the application with the new value rather than mutating it."],"exampleFix":"// before\nstatic void Main() {\n  using var game = new Game();\n  PlatformFolders.ApplicationDataSubDirectory = \"MyApp\"; // too late\n}\n// after\nstatic void Main() {\n  PlatformFolders.ApplicationDataSubDirectory = \"MyApp\";\n  using var game = new Game();\n}","handlingStrategy":"validation","validationCode":"if (PlatformFolders.IsVirtualFileSystemInitialized)\n    throw new InvalidOperationException(\"Set ApplicationDataSubDirectory earlier in startup\");","typeGuard":null,"tryCatchPattern":"try { PlatformFolders.ApplicationDataSubDirectory = dir; }\ncatch (InvalidOperationException)\n{\n    // VFS already initialized: fail startup or restart with the right value\n}","preventionTips":["Set all PlatformFolders/VFS configuration at the very top of Main, before any Stride object is constructed.","Centralize engine bootstrap in one method so configuration order is deterministic.","Avoid setting it from lazy static initializers that may run after engine init."],"tags":["invalid-operation","vfs","startup-order","configuration"],"backgroundTag":"invalid-state-transition","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}