Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Standalone InvalidOperationException on launch

Discussion in 'Entity Component System' started by jdtec, Feb 27, 2021.

  1. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    296
    I'm getting an InvalidOperationException in the Unity loading screen in standalone builds only.

    InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.


    It happens before any code in my project executes, as far as I can tell. There is no stack trace, just the above line in the player log.

    I tried attaching a debugger to the standalone app and saw this in the console:

    ERROR: Exception during construction of EventSource System.Collections. Concurrent.ConcurrentCollectionsEventSource


    I searched for this and found a link about newtonsoft.json causing this in Unity in some cases: https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/1812

    If anyone has any ideas how to further debug this or things to try I'd appreciate any help.

    This thread can be moved if it's not DOTs related. I'm not sure where best to post but it's only happening in my DOTs project when building from the new platform buildconfig asset.
     
    Last edited: Feb 27, 2021
  2. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    296
    In case it helps anyone in the future; I fixed this by disabling a generic singletons fast enter playmode static initialisation function.

    I wrapped the below in #if UNITY_EDITOR.

    [RuntimeInitializeOnLoadMethod (RuntimeInitializeLoadType.SubsystemRegistration)]
    static void FastEnterPlaymodeInit ()
    {
    m_ShuttingDown = false;
    m_Lock = new object ();
    m_Instance = null;
    }
     
    PartyBoat and GilCat like this.
  3. MicCode

    MicCode

    Joined:
    Nov 19, 2018
    Posts:
    58
    Thank you! Saved my time
    Code (CSharp):
    1. #if UNITY_EDITOR
    2.         [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
    3.         protected static void ResetSubsystem()
    4.         {
    5.             _instance = null;
    6.         }
    7. #endif
     
    jdtec likes this.
  4. randomdragon

    randomdragon

    Joined:
    Feb 11, 2020
    Posts:
    31
    Would you like to explain the meaning of subsystem registration? The manual was crude