Known causes for crashes exceptions - THDigi/SE-ModScript-Examples GitHub Wiki
Moved to SE wiki: https://spaceengineers.wiki.gg/wiki/Modding/Reference/Known_Solutions_to_crashes_or_errors
Old content
Whenever the game crashes it will log an exception in this format in the SE log:
<date&time> - Thread: <thread#> -> Exception occurred: <ExceptionType>: <ExceptionMessage>
at Some.NameSpace.SomeMethod(...)
at SomeOther.Name.Space.RunThat(...)
at DeeperStuff.DoThing(...)
etc.
This is often hard to decipher especially if you are not familiar with the game's insides, but regardless these errors are an important part to figuring out why it crashed.
Below I will list some vague crashes that have known causes which is primarily important to modders.
If you're a player then first you need to identify if it's a mod causing the crash and then either report the crash (with the SE log or the exception text) to the mod author, or to Keen's support site if it's not a mod causing it.
If you are a modder and the error is not in the list, you should ask in Keen's Discord server at #modding-programming if you're using C#, or #modding-art-sbc if you're doing only SBC stuff.
- IndexOutOfRangeException / Base6Directions.GetDirection
- KeyNotFoundException / MyResourceDistributorComponent.GetTypeIndex
- ArgumentNullException / MyBillboardRenderer.GatherInternal
- NullReferenceException / PasteGridData.Callback
- MOD_CRITICAL_ERROR / MyCubeBlockDefinition.Init
- MOD_CRITICAL_ERROR / LOADED ONLY n/6 PHASES
- Exception during loading of type : MyEmoteSwitcher
- IndexOutOfRangeException / MyHwBuffers.GetVertexBuffer
- KeyNotFoundException / MyMeshes.CreateSections
- NullReferenceException / MyMotorSuspension.CanPlaceRotor
- SaveFinished: failed to save the world / at System.Environment.GetStackTrace
- NullReferenceException / MyAutopilotComponent.UpdateGyro
- Value cannot be null / MyObjectFactory.GetProducedType
- NullReferenceException / MySession.GatherVicinityInformation
- Fatal error compiling / MyBlacklistSyntaxVisitor.VisitAttribute
- ArgumentNullException / MyDefinitionManager.InitBlockGroups
- NullReferenceException / MyBlockBuilderBase.AddFastBuildModelWithSubparts
- Input string was not in a correct format. / StringBuilder.FormatError / MyBlueprintDefinitionBase.ToString
- ArgumentNullException / FirstOrDefault() at PostprocessRadialMenus()
Thread: 1 -> Exception occurred: System.IndexOutOfRangeException: Index was outside the bounds of the array.
at VRageMath.Base6Directions.GetDirection(Vector3& vec)
at Sandbox.Game.GameSystems.Conveyors.MyConveyorLine.GetBlockLinePositions(MyCubeBlock block)
at Sandbox.Game.GameSystems.Conveyors.MyMultilineConveyorEndpoint..ctor(MyCubeBlock myBlock)
...
Caused by having a conveyor dummy span over multiple directions.
Thread: 1 -> Exception occurred: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Sandbox.Game.EntityComponents.MyResourceDistributorComponent.GetTypeIndex(MyDefinitionId& typeId)
at Sandbox.Game.EntityComponents.MyResourceDistributorComponent.source_MaxOutputChanged(MyDefinitionId changedResourceTypeId, Single oldOutput, MyResourceSourceComponent obj)
at Sandbox.Game.EntityComponents.MyResourceSourceComponent.SetMaxOutputByType(MyDefinitionId resourceTypeId, Single newMaxOutput)
at Sandbox.Game.Entities.Blocks.MyGasGenerator.SetRemainingCapacities()
at Sandbox.Game.Entities.Blocks.MyGasGenerator.UpdateAfterSimulation()
...
Caused when all these are true:
- EnableOxygen turned off in world settings.
- A GasGenerator block that does not have oxygen in its definitions.
- Said GasGenerator being placed on a grid that does not have any oxygen-related blocks (placing it in mid-air qualifies).
Thread: 11 -> Exception occured: System.ArgumentNullException: Value cannot be null.
Parameter name: key
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
at VRageRender.MyBillboardRenderer.GatherInternal()
...
A transparent material definition's file doesn't actually exist.
Thread: 1 -> Exception occurred: System.NullReferenceException: Object reference not set to an instance of an object.
at Sandbox.Game.Entities.MyCubeGrid.PasteGridData.Callback()
at ParallelTasks.Parallel.RunCallbacks()
at Sandbox.Game.World.MySession.Update(MyTimeSpan updateTime)
...
One cause can be that there's an armor skin id that no longer exists, on the blocks in the pasted grid.
There may be lots of other causes as this code does lots of things and the error is one of the most common kinds of errors.
MOD_CRITICAL_ERROR: <ModName>, in file: <FileNameButProbablyALie>
MOD PARTIALLY SKIPPED, LOADED ONLY 4/6 PHASES, Following Error occured:
Object reference not set to an instance of an object.
Sandbox.Game
at Sandbox.Definitions.MyCubeBlockDefinition.Init(MyObjectBuilder_DefinitionBase builder)
at Sandbox.Definitions.MyDefinitionManager.InitDefinition[T](MyModContext context, MyObjectBuilder_DefinitionBase builder)
at Sandbox.Definitions.MyDefinitionManager.ToDefinitions(MyModContext context, DefinitionDictionary`1 outputDefinitions, DefinitionDictionary`1[] outputCubeBlocks, MyObjectBuilder_CubeBlockDefinition[] cubeBlocks, Boolean failOnDebug)
at Sandbox.Definitions.MyDefinitionManager.LoadPhase3(MyObjectBuilder_Definitions objBuilder, MyModContext context, DefinitionSet definitionSet, Boolean failOnDebug)
...
This MyCubeBlockDefinition.Init()
in general is from generic block definition being initialized, stuff that all blocks have.
Most common causes:
- one or more component subtypes don't exist (if you use a component from another mod, have that mod be loaded before yours, by it being lower in the mods window list)
- the
<CriticalComponent ... />
tag is not declared or its component also does not exist. - any of the other common block tags might be missing or have an unexpected value, ensure you're copying the vanilla counterpart for the block type you want to use, don't transform definitions from one type to another!
MOD_CRITICAL_ERROR: <ModName>, in file:
MOD PARTIALLY SKIPPED, LOADED ONLY 1/6 PHASES, Following Error occured:
Object reference not set to an instance of an object.
Sandbox.Game
at Sandbox.Definitions.MyDefinitionManager.LoadDefinitions(List`1 contexts, List`1 definitionSets, Boolean failOnDebug, Boolean isPreload)
MOD_CRITICAL_ERROR: <ModName>, in file:
MOD PARTIALLY SKIPPED, LOADED ONLY 2/6 PHASES, Following Error occured:
Object reference not set to an instance of an object.
Sandbox.Game
at Sandbox.Definitions.MyDefinitionManager.LoadDefinitions(List`1 contexts, List`1 definitionSets, Boolean failOnDebug, Boolean isPreload)
MOD_CRITICAL_ERROR: <ModName>, in file:
MOD PARTIALLY SKIPPED, LOADED ONLY 3/6 PHASES, Following Error occured:
Object reference not set to an instance of an object.
Sandbox.Game
at Sandbox.Definitions.MyDefinitionManager.LoadDefinitions(List`1 contexts, List`1 definitionSets, Boolean failOnDebug, Boolean isPreload)
MOD_CRITICAL_ERROR: <ModName>, in file:
MOD PARTIALLY SKIPPED, LOADED ONLY 4/6 PHASES, Following Error occured:
Object reference not set to an instance of an object.
Sandbox.Game
at Sandbox.Definitions.MyDefinitionManager.LoadDefinitions(List`1 contexts, List`1 definitionSets, Boolean failOnDebug, Boolean isPreload)
MOD_CRITICAL_ERROR: <ModName>, in file:
MOD PARTIALLY SKIPPED, LOADED ONLY 5/6 PHASES, Following Error occured:
Object reference not set to an instance of an object.
Sandbox.Game
at Sandbox.Definitions.MyDefinitionManager.LoadDefinitions(List`1 contexts, List`1 definitionSets, Boolean failOnDebug, Boolean isPreload)
MOD_CRITICAL_ERROR: <ModName>, in file:
MOD PARTIALLY SKIPPED, LOADED ONLY 6/6 PHASES, Following Error occured:
Object reference not set to an instance of an object.
This is caused by too many things, lots unknown, here's some known ones:
- mod does not contain a Data folder (this also applies to mod.io zips, the Data folder needs to be at the root of the zip, no intermediate folder inside).
- local mod no longer exists (renamed its folder).
- download corruption (Fix to download corruption).
- many other unknowns...
Exception during loading of type : MyEmoteSwitcher
...
System.NullReferenceException: Object reference not set to an instance of an object.
at Sandbox.Game.Screens.Helpers.MyGuiControlDPad..ctor(MyObjectBuilder_DPadControlVisualStyle style)
...
Caused by emote icon missing, apparently it is quite strict about those.
Thread: 22 -> Exception occured: System.IndexOutOfRangeException: Index was outside the bounds of the array.
at VRage.Render11.Resources.MyHwBuffers.GetVertexBuffer(VertexBufferId id)
at VRageRender.MyRenderingPass.BindProxyGeometry(MyRenderableProxy proxy, MyRenderContext rc)
at VRageRender.MyGBufferPass.RecordCommandsInternal(MyRenderableProxy proxy)
...
One cause is model not UV mapped.
Thread: 10 -> Exception occured: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at VRageRender.MyMeshes.CreateSections(MyMeshData meshData, MyMeshPartInfo1[] parts, MyMeshSectionInfo1[]& sections)
at VRageRender.MyMeshes.CreatePartInfos(String assetName, String contentPath, MyMeshData meshData, MyLodMeshInfo& lodMeshInfo, MyMeshPartInfo1[]& parts, MyMeshSectionInfo1[]& sections)
at VRageRender.MyMeshes.LoadMwm(MyLodMeshInfo& lodMeshInfo, MyMeshPartInfo1[]& parts, MyMeshSectionInfo1[]& sections, MyLODDescriptor[]& lodDescriptors, Single rescale)
...
One cause is a model has UV maps but it's improperly unwrapped (zero size UV?)
Thread: 1 -> Exception occurred: System.NullReferenceException: Object reference not set to an instance of an object.
at Sandbox.Game.Entities.Cube.MyMotorSuspension.CanPlaceRotor(MyAttachableTopBlockBase rotorBlock, Int64 builtBy)
at Sandbox.Game.Entities.Blocks.MyMechanicalConnectionBlockBase.CreateTopPart(MyAttachableTopBlockBase& topBlock, Int64 builtBy, MyCubeBlockDefinitionGroup topGroup, Boolean smallToLarge, Boolean instantBuild)
at Sandbox.Game.Entities.Blocks.MyMechanicalConnectionBlockBase.CreateTopPartAndAttach(Int64 builtBy, Boolean smallToLarge, Boolean instantBuild)
at Sandbox.Game.Entities.Blocks.MyMechanicalConnectionBlockBase.OnBuildSuccess(Int64 builtBy, Boolean instantBuild)
at Sandbox.Game.Entities.MyCubeBuilder.AfterGridBuild(MyEntity builder, MyCubeGrid grid, Boolean instantBuild, UInt64 senderId)
...
Likely caused by the wheel model not having a collider.
Thread: 1 -> SaveFinished: failed to save the world at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at Sandbox.Game.Screens.Helpers.MyAsyncSaving.SaveFinished(MySessionSnapshot snapshot)
at ParallelTasks.Parallel.RunCallbacks()
at Sandbox.Game.World.MySession.Update(MyTimeSpan updateTime)
...
One cause is that the world name has a trailing space, check VRage log to see if it complains about being unable to write the screenshot.
Thread: 1 -> Exception occurred: System.NullReferenceException: Object reference not set to an instance of an object.
at Sandbox.Game.EntityComponents.MyAutopilotComponent.UpdateGyro(Vector3D deltaPos, Vector3D perpDeltaPos, Boolean& rotating, Boolean& isLabile, Double& angleRadians, Boolean preciseRotation)
at Sandbox.Game.EntityComponents.MyAutopilotComponent.UpdateAutopilot()
at Sandbox.Game.Entities.MyRemoteControl.UpdateBeforeSimulationParallel()
...
In Automatons Beta update (might not still be an issue later) the remote control blocks require an entity component or enabling autopilot on them will crash the game.
See EntityComponents.sbc for AutopilotComponent (and reminder that EntityContainers.sbc links components to blocks).
Value cannot be null.
Parameter name: key
mscorlib
at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at VRage.ObjectBuilders.MyObjectFactory`2.GetProducedType(MyObjectBuilderType objectBuilderType)
This one can happen on any definition and it means its TypeId
does not exist.
Mods cannot invent TypeId, only SubTypeId.
Thread: 1 -> Exception occurred: System.NullReferenceException: Object reference not set to an instance of an object.
at Sandbox.Game.World.MySession.<>c__DisplayClass613_1.<GatherVicinityInformation>b__0()
at System.DelegateExtensions.InvokeIfNotNull(Action handler)
at Sandbox.Game.World.MySession.GatherVicinityInformation(BoundingSphereD bs, HashSet`1 voxelMaterials, HashSet`1 models, HashSet`1 armorModels, Action completion)
at Sandbox.Game.World.MySession.GatherVicinityInformation(MyObjectBuilder_Checkpoint checkpoint)
at Sandbox.Game.World.MySession.Save(MySessionSnapshot& snapshot, String customSaveName)
...
One known cause is using a modded character in another world causing its subtype to be saved to ActiveInventory.sbl where it attempts to use it in all worlds, and causes this error when the modded character no longer exists.
Workaround is to open ActiveInventory.sbl (it's XML, and it's in the %appdata%/SpaceEngineers/Saves
folder), then change <Model>
to be Default_Astronaut
or Default_Astronaut_Female
.
Fatal error compiling Steam:<ModName> - <FolderName>. This item is likely not a mod and should be removed from the mod list.
Exception occurred: System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at VRage.Scripting.MyBlacklistSyntaxVisitor.VisitAttribute(AttributeSyntax node)
at VRage.Scripting.MyBlacklistSyntaxVisitor.Visit(SyntaxNode node)
...
at VRage.Scripting.MyScriptCompiler.<Compile>d__37.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Sandbox.Game.World.MyScriptManager.Compile(IEnumerable`1 scriptFiles, String assemblyName, Boolean zipped, MyModContext context)
at Sandbox.Game.World.MyScriptManager.LoadScripts(String path, MyModContext mod)
at Sandbox.Game.World.MyScriptManager.LoadData()
---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.
at VRage.Scripting.MyBlacklistSyntaxVisitor.VisitAttribute(AttributeSyntax node)
at VRage.Scripting.MyBlacklistSyntaxVisitor.Visit(SyntaxNode node)
...
at VRage.Scripting.MyScriptCompiler.<Compile>d__37.MoveNext()<---
The message of "likely not a mod" is generally from adding PB scripts, ship blueprints or worlds as mods, but in this particular exception with MyBlacklistSyntaxVisitor.VisitAttribute
it's caused by an attribute in C# code syntax.
One example that triggers this error:
[MyEntityComponentDescriptor(typeof(MyObjectBuilder_CargoContainer), false), "SomeSubtype"]
The MyEntityComponentDescriptor's closing paranthesis closes before the last string, which seems to break the game's script analyzer.
Thread: 1 -> Error: Error during loading session:System.ArgumentNullException: Value cannot be null.
Parameter name: key
at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
at Sandbox.Definitions.MyDefinitionManager.InitBlockGroups()
at Sandbox.Definitions.MyDefinitionManager.LoadPostProcess()
at Sandbox.Definitions.MyDefinitionManager.LoadData(List`1 mods)
...
Caused by a block definition without a <BlockPairName>
declared.
Thread: 1 -> Exception occurred: System.NullReferenceException: Object reference not set to an instance of an object.
at Sandbox.Game.Entities.MyBlockBuilderBase.AddFastBuildModelWithSubparts(MatrixD& matrix, List1 matrices, List1 models, MyCubeBlockDefinition blockDefinition, Single gridScale)
at Sandbox.Game.Entities.MyCubeBuilder.AddFastBuildModels(MatrixD baseMatrix, Matrix& localMatrixAdd, List1 matrices, List1 models, MyCubeBlockDefinition definition, Nullable1 startBuild, Nullable1 continueBuild)
at Sandbox.Game.Entities.MyCubeBuilder.UpdateGizmo_Grid(MyGizmoSpaceProperties gizmoSpace, Boolean add, Boolean remove, Boolean draw)
at Sandbox.Game.Entities.MyCubeBuilder.UpdateGizmos(Boolean addPos, Boolean removePos, Boolean draw)
...
One known cause for this is <MirroringBlock>
not being the same type as the held block.
Input string was not in a correct format. / StringBuilder.FormatError / MyBlueprintDefinitionBase.ToString
MOD_CRITICAL_ERROR: <ModName>, in file: <File>
MOD PARTIALLY SKIPPED, LOADED ONLY 2/6 PHASES, Following Error occured:
Input string was not in a correct format.
mscorlib
at System.Text.StringBuilder.FormatError()
at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
at Sandbox.Definitions.MyBlueprintDefinitionBase.ToString()
at System.String.Concat(Object[] args)
at Sandbox.Definitions.MyDefinitionManager.InitBlueprints(MyModContext context, Dictionary2 output, DefinitionDictionary1 blueprintsByResult, MyObjectBuilder_BlueprintDefinition[] blueprints, Boolean failOnDebug)
at Sandbox.Definitions.MyDefinitionManager.LoadPhase1(MyObjectBuilder_Definitions objBuilder, MyModContext context, DefinitionSet definitionSet, Boolean failOnDebug)
at Sandbox.Definitions.MyDefinitionManager.LoadDefinitions(List1 contexts, List1 definitionSets, Boolean failOnDebug, Boolean isPreload)
...
Caused by having {
or }
in the <DisplayName>
of a blueprint that has same result as another blueprint, causing the game to print a message in log and that's where it crashes, because it weirdly mixes formatting techniques causing a format exception from the presence of those characters (which are used for the formatting).
TL;DR it's a game bug.
Solutions:
- Remove
{
and}
from the blueprint<DisplayName>
. - Replace
{
and}
with{{
and}}
which will show up as{Actual Blueprint Name}
in-game. - Use a localization script to load .resx and then you can use localization keys directly without surrounding
{LOC:
and}
, just like Keen uses them.
Thread: 1 -> Error: Error during loading session:System.ArgumentNullException: Value cannot be null.
Parameter name: source
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
at Sandbox.Definitions.MyDefinitionManager.PostprocessRadialMenus()
at Sandbox.Definitions.MyDefinitionManager.LoadPostProcess()
at Sandbox.Definitions.MyDefinitionManager.LoadData(List`1 mods)
...
This is caused by a block that does not have any <Icon>
defined.