'How to handle this "InvalidOperationException: EnsureRunningOnMainThread can only be called from the main thread"

I Have been getting this error for quite a while now, no idea what it is. it is not intervening in my progress either!

full Error Message:

 InvalidOperationException: EnsureRunningOnMainThread can only be called from the main thread
 UnityEngine.Object.EnsureRunningOnMainThread () (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:153)
 UnityEngine.Object.GetInstanceID () (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:73)
 UnityEngine.Object.IsNativeObjectAlive (UnityEngine.Object o) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:182)
 UnityEngine.Object.CompareBaseObjects (UnityEngine.Object lhs, UnityEngine.Object rhs) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:140)
 UnityEngine.Object.op_Inequality (UnityEngine.Object x, UnityEngine.Object y) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:405)
 UnityEditor.ProGrids.GridRenderer.Destroy () (at Library/PackageCache/[email protected]/Editor/GridRenderer.cs:85)
 UnityEditor.ProGrids.ProGridsEditor.Destroy () (at Library/PackageCache/[email protected]/Editor/ProGridsEditor.cs:409)
 UnityEditor.ProGrids.ProGridsEditor.Finalize () (at Library/PackageCache/[email protected]/Editor/ProGridsEditor.cs:370)
 UnityEngine.UnhandledExceptionHandler:<RegisterUECatcher>m__0(Object, UnhandledExceptionEventArgs)

Any suggestions?



Solution 1:[1]

It looks like bug in ProGrids 303. They're finalizing from worker thread where it's a no-go. Ignore. Will disappear on next update surely.

Solution 2:[2]

This might be an issue with the installed packages.

Try to update all packages with the package manager to solve this issue. If you are having any old package folder in the Assets folder you can delete it and try to add it again from the package manager or from a unity package.

Also, ensure that your target platform libraries are not colliding which means there might be the same library files in a different folder. In that case, delete one of them and try to build it again.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andrew ?ukasik
Solution 2 Codemaker