Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved NetworkBehaviourILPP compiler error upgrading project to Unity 2022 LTS

Discussion in 'Netcode for GameObjects' started by Brogan89, Jul 24, 2023.

  1. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    244
    Hello. I'm currently trying to upgrade our project to Unity 2022 LTS but having difficulty tracking down a compiler issue.

    The error is:

    Code (CSharp):
    1. Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP: (0,0): error  - System.NullReferenceException: Object reference not set to an instance of an object.||   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.GenerateVariableInitialization(TypeDefinition type)||   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.GenerateVariableInitialization(TypeDefinition type)||   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.ProcessNetworkBehaviour(TypeDefinition typeDefinition, String[] assemblyDefines)||   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.<>c__DisplayClass7_0.<Process>b__1(TypeDefinition b)||   at System.Collections.Generic.List`1.ForEach(Action`1 action)||   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.Process(ICompiledAssembly compiledAssembly)   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.GenerateVariableInitialization(TypeDefinition type)||   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.GenerateVariableInitialization(TypeDefinition type)||   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.ProcessNetworkBehaviour(TypeDefinition typeDefinition, String[] assemblyDefines)||   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.<>c__DisplayClass7_0.<Process>b__1(TypeDefinition b)||   at System.Collections.Generic.List`1.ForEach(Action`1 action)||   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.Process(ICompiledAssembly compiledAssembly)
    I found a GitHub issue related to the issue but it seems as its reported fixed.

    I've tried a bunch of things, messing around with different script defines and updating/rolling packages without any progress.

    I've also got another netcode project in Unity 2022 and everything is working fine.

    So I'm really struggling to figure out what is causing the issue above.

    Any insight into this would really appreciated.


    Thanks.
     
  2. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    638
    I don't know if it will fix your issue but there's a couple of ILPP fixes on the develop branch.
     
    Brogan89 likes this.
  3. Mj-Kkaya

    Mj-Kkaya

    Joined:
    Oct 10, 2017
    Posts:
    175
    Hi @Brogan89 , Have you ever scene this issue page?
    This problem is comes from "class Singleton<T>:NetworkBehaviour" usage.
    I hope it will be help you.
     
    Brogan89 likes this.
  4. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    244
    Yeah, I did come across a forum or something mentioning that. I do have a class like that and I removed all instances of it and it still didn't help. I can't remember if I regenerated the csproj files or not afterwards though... I'll give that another look today. Cheers.

    I also stumbled into someone talking about NetworkList<T> issues and NetworkBehaviourILPP. I did a similar purge of serialised NetworkLists but still no go :(
     
  5. Mj-Kkaya

    Mj-Kkaya

    Joined:
    Oct 10, 2017
    Posts:
    175
    Did you remove those code? Or deleted only the references?
    You have to remove all code.
     
    Brogan89 likes this.
  6. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    244
    It turns out I missed another instance of this I was unaware of. I did a proper culling this time and now it compiles!

    Thanks so much for pointing that out. The error log does not help diagnose the problem.
     
    Mj-Kkaya likes this.