InvalidOperationException: Could not execute the method

Hello. I am sorry to bother you. When I started my application, it showed an error messages like below. but sadly It just said “Filename: Line: -1”, so I couldn’t know which points has error. I guessed Unity Player tried to execute something before it loaded completed. is there any options or solutions for this?

Unity Version:
2019.3.6f1

Error Messages

2020-05-19 15:37:29.766 22555 22601 Error Unity InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.
2020-05-19 15:37:29.766 22555 22601 Error Unity
2020-05-19 15:37:29.766 22555 22601 Error Unity
2020-05-19 15:37:29.766 22555 22601 Error Unity (Filename: Line: -1)
2020-05-19 15:37:29.766 22555 22601 Error Unity

it doesn’t make application crashed. but it is really annoying to me. how can I fix it?

Did you try using Development Player?

you mean the “Development build”? yes I checked the development build option

You could attach managed debugger to your app, and enable breakpoint on InvalidOperationException.

I will try. but the error message occured when the application started. this messages showed while the unity logo came out

I’m getting this as well, in 2019.3.14. It actually does crash if using IL2CPP. This seems to be a recent bug, the only other reference I can find is someone else’s game

Any updates on this?
I’m having it too on version 2020.1.8

Error report

Mono path[0] = ‘E:/Unity Projects/Braveless/BUILDS/Latest version/WINDOWS/Braveless_Data/Managed’
Mono config path = ‘E:/Unity Projects/Braveless/BUILDS/Latest version/WINDOWS/MonoBleedingEdge/etc’
PlayerConnection initialized from E:/Unity Projects/Braveless/BUILDS/Latest version/WINDOWS/Braveless_Data (debug = 0)
PlayerConnection initialized network socket : 0.0.0.0 55264
Multi-casting “[IP] 192.168.1.36 [Port] 55264 [Flags] 2 [Guid] 4273238775 [EditorId] 2912726357 [Version] 1048832 [Id] WindowsPlayer(Feast-Sager) [Debug] 0 [PackageName] WindowsPlayer [ProjectName] Braveless” to [225.0.0.222:54997]…
Started listening to [0.0.0.0:55264]
PlayerConnection already initialized - listening to [0.0.0.0:55264]
Initialize engine version: 2020.1.8f1 (22e8c0b0c3ec)
[Subsystems] Discovering subsystems at path E:/Unity Projects/Braveless/BUILDS/Latest version/WINDOWS/Braveless_Data/UnitySubsystems
GfxDevice: creating device client; threaded=1
Direct3D:
Version: Direct3D 11.0 [level 11.1]
Renderer: NVIDIA GeForce GTX 980 (ID=0x161a)
Vendor:
VRAM: 8144 MB
Driver: 27.21.14.5167
Begin MonoManager ReloadAssembly

  • Completed reload, in 0.571 seconds
    D3D11 device created for Microsoft Media Foundation video decoding.
    Uploading Crash Report
    InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.

(Filename: Line: -1)

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

(Filename: Line: -1)

Initializing input.

New input system (experimental) initialized
Input initialized.

Initialized touch support.

UnloadTime: 1.082500 ms

Unloading 5 Unused Serialized files (Serialized files now loaded: 0)
UnloadTime: 5.913200 ms
System memory in use before: 189.1 MB.
System memory in use after: 189.2 MB.

Unloading 12 unused Assets to reduce memory usage. Loaded Objects now: 16515.
Total: 20.725900 ms (FindLiveObjects: 1.072100 ms CreateObjectMapping: 0.999400 ms MarkObjects: 18.494400 ms DeleteObjects: 0.158800 ms)

Uploading Crash Report

Also getting this on 2020.2.b13

Mono path[0] = '/Users/Jon/Dropbox/UnityProjects/ProtoAS/Builds/macOSClassicBuildConfiguration/proto_rts.app/Contents/Resources/Data/Managed'
Mono config path = '/Users/Jon/Dropbox/UnityProjects/ProtoAS/Builds/macOSClassicBuildConfiguration/proto_rts.app/Contents/MonoBleedingEdge/etc'
PlayerConnection initialized from /Users/Jon/Dropbox/UnityProjects/ProtoAS/Builds/macOSClassicBuildConfiguration/proto_rts.app/Contents/Resources/Data (debug = 0)
PlayerConnection initialized network socket : 0.0.0.0 55359
Multi-casting "[IP] 192.168.1.66 [Port] 55359 [Flags] 2 [Guid] 2266093818 [EditorId] 4178015578 [Version] 1048832 [Id] OSXPlayer(Jons-MBP-2013.lan) [Debug] 0 [PackageName] OSXPlayer [ProjectName] proto_rts" to [225.0.0.222:54997]...
Started listening to [0.0.0.0:55359]
PlayerConnection already initialized - listening to [0.0.0.0:55359]
Initialize engine version: 2020.2.0b13 (655e1a328b90)
[Subsystems] Discovering subsystems at path /Users/Jon/Dropbox/UnityProjects/ProtoAS/Builds/macOSClassicBuildConfiguration/proto_rts.app/Contents/Resources/Data/UnitySubsystems
GfxDevice: creating device client; threaded=1
2020-12-07 20:11:16.175 proto_rts[88016:3702592] DELL U2715H preferred device: NVIDIA GeForce GT 750M (high power)
2020-12-07 20:11:16.175 proto_rts[88016:3702592] Metal devices available: 2
2020-12-07 20:11:16.175 proto_rts[88016:3702592] 0: NVIDIA GeForce GT 750M (high power)
2020-12-07 20:11:16.175 proto_rts[88016:3702592] 1: Intel Iris Pro Graphics (low power)
2020-12-07 20:11:16.175 proto_rts[88016:3702592] Using device NVIDIA GeForce GT 750M (high power)
Initializing Metal device caps: NVIDIA GeForce GT 750M
Begin MonoManager ReloadAssembly
Symbol file LoadedFromMemory is not a mono symbol file
- Completed reload, in  0.120 seconds
Uploading Crash Report
InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.


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

I realize this is an old thread, but I when I build my game I am receiving a similar error.

Doesn’t cause the game to crash, but it seems as if many gameplay elements relating to custom interfaces and scriptable objects are completely broken in the game and just don’t function (Null Ref Exceptions further in the logs). Investigating myself, and not quite sure where to look for more help on this, but can certainly provide more details if needed.

Any traction on this issue in recent months?

Player Error Logs


Initialize engine version: 2020.2.5f1 (e2c53f129de5)

GfxDevice: creating device client; threaded=1
Direct3D:
Version: Direct3D 11.0 [level 11.1]
Renderer: NVIDIA GeForce GTX 1080 (ID=0x1b80)
Vendor:
VRAM: 8079 MB
Driver: 30.0.14.7111
Begin MonoManager ReloadAssembly

  • Completed reload, in 0.071 seconds
    D3D11 device created for Microsoft Media Foundation video decoding.
    Initializing input.
    Input initialized.
    Initialized touch support.
    UnloadTime: 0.752900 ms
    InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.
    InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.
    InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.
    InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.
    InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.
    InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.
    InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.
    InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.
    InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.
    InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.
    InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.
    InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.
    InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.
    InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.
    InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.

NullReferenceException: Object reference not set to an instance of an object
at Relic.Core.Game.rSpawner.Awake () [0x00068] in <2e5bbfbc4b134a98bdd3edaba0408e4c>:0

I am getting this on Windows and Linux builds too, only in builds.

Same only in build in 2021.1.21

I tracked it down coming from an [InitializeOnEnterPlaymode] used to reset a static Dictionary in a struct. It’s probably the same case for RuntimeInitializeOnLoadMethod in builds, didn’t tested it yet.

// part of non-static struct type
private static readonly s_Dictionary<int, SomeValue> s_Dictionary = new Dictionary<int, SomeValue>();

#if UNITY_EDITOR
    [InitializeOnEnterPlayMode] // <-- uncommenting this removed the error in the Editor
#else
    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
#endif
private static void ResetOnLoad()
{
    s_Dictionary.Clear();
}

The Doc states it can be used for Editor-CLASS methods, so structs doesn’t seem to be supported.
https://docs.unity3d.com/ScriptReference/InitializeOnEnterPlayModeAttribute.html

Update, made it a class to test it, still get the error, so forget what I’ve written about the struct, but still only happens when the attribute is not commented out.

Okay, I found the issue, for anyone stumbling upon this thread here’s what caused this in my project:

I had a generic struct with a static field to be reset, I guess unity tried to call the function for sth like SomeStruct but the “containing”-type SomeStruct was not “instantiated”/parsed whatever magic happens there, yet:
“Could not execute the method because the containing type is not fully instantiated.”

So after thinking it may not work with structs I tried it with a class, same issue.Since the field to be resetted had nothing to do with the generic-type I separated both and made the non-generic part an abstract base class to be inherited from a derived generic child-type.
With now the reset-code inside the abstract base part the error no longer occurs, and is called correctly, ofc this wont work with structs, since they only can inherit interfaces. Here’s the dummy code I used to check how I can work arround that:

    // works
    public struct SomeStruct
    {
        private static int s_fieldToReset = 0;
    
#if UNITY_EDITOR
        [InitializeOnEnterPlayMode]
#endif
        private static void ResetOnLoad()
        {
            s_fieldToReset = 0;
        }
    }
 

    // causes the exception (also if it's an struct doesn't matter):
    public class SomeGenericClass<T>
    {
        private static int s_fieldToReset = 0;
        private T someOtherThing;
    
#if UNITY_EDITOR
        [InitializeOnEnterPlayMode]
#endif
        private static void ResetOnLoad()
        {
            s_fieldToReset = 0;
        }
    }
 

    // combination of the following works though:
    public abstract class SomeBaseClass
    {
        private static int s_fieldToReset = 0;
    
#if UNITY_EDITOR
        [InitializeOnEnterPlayMode]
#endif
        private static void ResetOnLoad()
        {
            s_fieldToReset = 0;
        }
    }

    public class SomeGenericClassThatWorks<T> : SomeBaseClass
    {
        private T someOtherThing;
    }

What you might want to test (I didn’t) is whether it works if you keep the SomeGenericClass<T> that causes the exception above and try to define a concrete derrived type, maybe Unity/TheCompiler can interpret this correctly in that case idk:

public class ConcreteClass : SomeGenericClass<OtherType>
{}
2 Likes