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

InvalidOperationException: Could not execute the method

Discussion in 'Android' started by escon1004, May 19, 2020.

  1. escon1004

    escon1004

    Joined:
    Apr 15, 2020
    Posts:
    9
    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

    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?
     
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    Did you try using Development Player?
     
  3. escon1004

    escon1004

    Joined:
    Apr 15, 2020
    Posts:
    9
    you mean the "Development build"? yes I checked the development build option
     
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    You could attach managed debugger to your app, and enable breakpoint on InvalidOperationException.
     
  5. escon1004

    escon1004

    Joined:
    Apr 15, 2020
    Posts:
    9
    I will try. but the error message occured when the application started. this messages showed while the unity logo came out
     
  6. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    313
  7. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    974
    Any updates on this?
    I'm having it too on version 2020.1.8

    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)

    <RI> Initializing input.

    New input system (experimental) initialized
    <RI> Input initialized.

    <RI> 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
     
  8. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    297
    Also getting this on 2020.2.b13

    Code (CSharp):
    1. Mono path[0] = '/Users/Jon/Dropbox/UnityProjects/ProtoAS/Builds/macOSClassicBuildConfiguration/proto_rts.app/Contents/Resources/Data/Managed'
    2. Mono config path = '/Users/Jon/Dropbox/UnityProjects/ProtoAS/Builds/macOSClassicBuildConfiguration/proto_rts.app/Contents/MonoBleedingEdge/etc'
    3. PlayerConnection initialized from /Users/Jon/Dropbox/UnityProjects/ProtoAS/Builds/macOSClassicBuildConfiguration/proto_rts.app/Contents/Resources/Data (debug = 0)
    4. PlayerConnection initialized network socket : 0.0.0.0 55359
    5. 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]...
    6. Started listening to [0.0.0.0:55359]
    7. PlayerConnection already initialized - listening to [0.0.0.0:55359]
    8. Initialize engine version: 2020.2.0b13 (655e1a328b90)
    9. [Subsystems] Discovering subsystems at path /Users/Jon/Dropbox/UnityProjects/ProtoAS/Builds/macOSClassicBuildConfiguration/proto_rts.app/Contents/Resources/Data/UnitySubsystems
    10. GfxDevice: creating device client; threaded=1
    11. 2020-12-07 20:11:16.175 proto_rts[88016:3702592] DELL U2715H preferred device: NVIDIA GeForce GT 750M (high power)
    12. 2020-12-07 20:11:16.175 proto_rts[88016:3702592] Metal devices available: 2
    13. 2020-12-07 20:11:16.175 proto_rts[88016:3702592] 0: NVIDIA GeForce GT 750M (high power)
    14. 2020-12-07 20:11:16.175 proto_rts[88016:3702592] 1: Intel Iris Pro Graphics (low power)
    15. 2020-12-07 20:11:16.175 proto_rts[88016:3702592] Using device NVIDIA GeForce GT 750M (high power)
    16. Initializing Metal device caps: NVIDIA GeForce GT 750M
    17. Begin MonoManager ReloadAssembly
    18. Symbol file LoadedFromMemory is not a mono symbol file
    19. - Completed reload, in  0.120 seconds
    20. Uploading Crash Report
    21. InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.
    22.  
    23.  
    24. InvalidOperationException: Could not execute the method because the containing type is not fully instantiated.
     
  9. DivineBlade

    DivineBlade

    Joined:
    May 1, 2018
    Posts:
    7
    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?

    ...
    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.
    <RI> Initializing input.
    <RI> Input initialized.
    <RI> 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
     
  10. spajus

    spajus

    Joined:
    Jun 10, 2015
    Posts:
    43
    I am getting this on Windows and Linux builds too, only in builds.
     
  11. Morphus74

    Morphus74

    Joined:
    Jun 12, 2018
    Posts:
    174
    Same only in build in 2021.1.21
     
  12. Nefahl

    Nefahl

    Joined:
    Feb 20, 2017
    Posts:
    71
    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.

    Code (CSharp):
    1.  
    2. // part of non-static struct type
    3. private static readonly s_Dictionary<int, SomeValue> s_Dictionary = new Dictionary<int, SomeValue>();
    4.  
    5. #if UNITY_EDITOR
    6.     [InitializeOnEnterPlayMode] // <-- uncommenting this removed the error in the Editor
    7. #else
    8.     [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
    9. #endif
    10. private static void ResetOnLoad()
    11. {
    12.     s_Dictionary.Clear();
    13. }
    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.
     
    Last edited: Dec 7, 2022
  13. Nefahl

    Nefahl

    Joined:
    Feb 20, 2017
    Posts:
    71
    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<int> but the "containing"-type SomeStruct<T> 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:

    Code (CSharp):
    1.  
    2.     // works
    3.     public struct SomeStruct
    4.     {
    5.         private static int s_fieldToReset = 0;
    6.    
    7. #if UNITY_EDITOR
    8.         [InitializeOnEnterPlayMode]
    9. #endif
    10.         private static void ResetOnLoad()
    11.         {
    12.             s_fieldToReset = 0;
    13.         }
    14.     }
    15.  
    16.  
    17.     // causes the exception (also if it's an struct doesn't matter):
    18.     public class SomeGenericClass<T>
    19.     {
    20.         private static int s_fieldToReset = 0;
    21.         private T someOtherThing;
    22.    
    23. #if UNITY_EDITOR
    24.         [InitializeOnEnterPlayMode]
    25. #endif
    26.         private static void ResetOnLoad()
    27.         {
    28.             s_fieldToReset = 0;
    29.         }
    30.     }
    31.  
    32.  
    33.     // combination of the following works though:
    34.     public abstract class SomeBaseClass
    35.     {
    36.         private static int s_fieldToReset = 0;
    37.    
    38. #if UNITY_EDITOR
    39.         [InitializeOnEnterPlayMode]
    40. #endif
    41.         private static void ResetOnLoad()
    42.         {
    43.             s_fieldToReset = 0;
    44.         }
    45.     }
    46.  
    47.     public class SomeGenericClassThatWorks<T> : SomeBaseClass
    48.     {
    49.         private T someOtherThing;
    50.     }
    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:
    Code (CSharp):
    1. public class ConcreteClass : SomeGenericClass<OtherType>
    2. {}
     
    OBiwer likes this.