Porting a .net to unity: NullReferenceException: Object reference not set to an instance of an objec

Hi folks,

I have a running .net program, that works on console. Now I want to port it over and I am kinda a newbie in Unity. NullReferenceException: Object reference not set to an instance of an object
Here is the code:

This script is the entry point and is attached to an empty GameObject in the editor:

using UnityEngine;
namespace QuickstartClient
{
   
    public class Test : MonoBehaviour
    {
        // Start is called before the first frame update
        void Start()
        {
            QuickStart.SubscribeQAUpdate();
        }
        // Update is called once per frame
        void Update()
        {
        }
    }
}

and it calls that function in the class QuickStart:

namespace QuickstartClient
{
     private static LServer ls;
     class QuickStart : MonoBehavior
     {
        public static void SubscribeQAUpdate()
        {
            Debug.Log("... Starting Subscription!");

            Subscription qa_updates = new Subscription("MERGE");
            qa_updates.Fields = new string[7] { "timestamp", "message", };
            qa_updates.Items = new string[1] { "QA-Updater" };
            qa_updates.addListener(new QA_Listener());

            Debug.Log("... " + qa_updates.Fields[0]);
           ls.subscribe(qa_updates); \\------>Error

            Debug.Log("... Starting Subscription done!");
            }

ls.subscribe is from a .dll and the fileds are not empty.

Please, what should I do?
Thanks,Slarti

Where does “ls” come from ?

namespace QuickstartClient
{
     private static LServer ls;
     class QuickStart : MonoBehavior
     {
        public static void SubscribeQAUpdate()
...

and this is an external .dll that works.

must have dropped out by editing. I re-edited the post

ok then you have to instantiate this somewhere / somehow dont you ?

:roll_eyes::sweat_smile:
Oh gees … yes thanks.

ls = new LServer(x, y);

Thanks for helping a nooby

1 Like