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?
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
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)
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.
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 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();
}
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>
{}