question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

InvalidOperationException: EnsureRunningOnMainThread can only be called from the main thread

See original GitHub issue

Hi, I get this error when working with your class. Until now it works fine, and I can’t see where is the problem (I mean, I think I commented all the last changes before the error appears but still keep there…). Do you think there is some solution in your class? Here is the full stack error. Thank you.

InvalidOperationException: EnsureRunningOnMainThread can only be called from the main thread UnityEngine.Object.EnsureRunningOnMainThread () (at <c6b52566f59b49fc861a7812a1ea2f6b>:0) UnityEngine.Object.GetInstanceID () (at <c6b52566f59b49fc861a7812a1ea2f6b>:0) UnityEngine.Object.IsNativeObjectAlive (UnityEngine.Object o) (at <c6b52566f59b49fc861a7812a1ea2f6b>:0) UnityEngine.Object.CompareBaseObjects (UnityEngine.Object lhs, UnityEngine.Object rhs) (at <c6b52566f59b49fc861a7812a1ea2f6b>:0) UnityEngine.Object.op_Equality (UnityEngine.Object x, UnityEngine.Object y) (at <c6b52566f59b49fc861a7812a1ea2f6b>:0) UnityEngine.Object.Equals (System.Object other) (at <c6b52566f59b49fc861a7812a1ea2f6b>:0) System.Collections.Generic.ObjectEqualityComparer1[T].Equals (T x, T y) (at <c2a97e0383e8404c9fc0ae19d58f57f1>:0) System.Collections.Generic.Dictionary2[TKey,TValue].FindEntry (TKey key) (at <c2a97e0383e8404c9fc0ae19d58f57f1>:0) System.Collections.Generic.Dictionary2[TKey,TValue].ContainsKey (TKey key) (at <c2a97e0383e8404c9fc0ae19d58f57f1>:0) GenericDictionary2[TKey,TValue].ContainsKey (TKey key) (at Assets/Code/Libraries/GenericDictionary.cs:92) GenericDictionary`2[TKey,TValue].OnAfterDeserialize () (at Assets/Code/Libraries/GenericDictionary.cs:50)

Issue Analytics

  • State:open
  • Created 9 months ago
  • Comments:19 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
upscalebabycommented, Mar 22, 2023

I’ve kept this issue open since I suspected there was some issue with static initialization. I don’t use singletons so haven’t encountered this issue myself, but sounds like it’s pretty tricky to reproduce since it doesn’t occur immediately.

1reaction
Scorpincommented, Dec 21, 2022

Ok, can be… If I can reproduce the bug anyway I’ll advice you. Thank you for all 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

EnsureRunningOnMainThread can only be called from the ...
EnsureRunningOnMainThread can only be called from the main thread. Constructors and field initializers will be executed from the loading ...
Read more >
EnsureRunningOnMainThread can only be called from the ...
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....
Read more >
EnsureRunningOnMainThread can only be called from the ...
Test now fail with the below errors. InvalidOperationException: EnsureRunningOnMainThread can only be called from the main thread UnityEngine.
Read more >
"InvalidOperationException" Error - Forums
InvalidOperationException: EnsureRunningOnMainThread can only be called from the main thread UnityEngine.Object.EnsureRunningOnMainThread () (at ...
Read more >
TrySetSetString can only be called from the main thread.
I am using the Auth Sample in there to Signing an email/pass user: I receive an error: TrySetSetString can only be called from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found