Announcement

Collapse
No announcement yet.

NullRefere

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • NullRefere

    I'm trying to build example from GitHub

    Example suggest add this line to constructor
    this.networkService = WaveServices.GetService<NetworkService>();
    But 'networkService' still null. It's generate nullreferenceeception later.

    Here is a link to archive with my project: https://yadi.sk/d/Bu3Z1qiouNB9P

  • #2
    The problem is in your Game.cs file

    Code:
     public override void Initialize(IApplication application)
    {
    base.Initialize(application);
    
    ScreenContext screenContext = new ScreenContext(new MyScene());    
    WaveServices.ScreenContextManager.To(screenContext);
    
    WaveServices.RegisterService(new NetworkService());
    }
    You have to register your service before calling the MyScene constructor, because you are trying to retrieve the service there.

    Code:
     public override void Initialize(IApplication application)
    {
    base.Initialize(application);
    
    WaveServices.RegisterService(new NetworkService());
    
    ScreenContext screenContext = new ScreenContext(new MyScene());    
    WaveServices.ScreenContextManager.To(screenContext);
    
    }

    Comment


    • #3
      Hi Starostin13,

      As mrcoffee says you need to register a service before to use it, that why you receive null.

      But did you say that this an example of our github sample repository?


      Comment


      • #4
        Originally posted by JavierCanton View Post
        Hi Starostin13,

        As mrcoffee says you need to register a service before to use it, that why you receive null.

        But did you say that this an example of our github sample repository?

        Sorry for long delay. I mean this https://github.com/WaveEngine/Docume...ltiplayer-game. I think this point should be clarified.

        Meanwhile, when I update Game.cs file I get new exception that occurred when I'm try to start new client (I've attached screenshot also)
        {"Type is not expected, and no contract can be inferred: WaveEngine.Framework.Entity"}

        Have some ideas here?

        P.S.: Great thanks to mrcoffee
        Attached Files

        Comment


        • #5
          Edited the github.

          Comment

          Working...
          X