NullReferenceException on a StartCoroutine

Hello

I have a NullReferenceException on a StartCoroutine call, even if i delete all the content of it.

Here is a sample of my code :

public class csGUI : MonoBehaviour
{
    void OnGUI()
    {
        if (GUI.Button(new Rect(560, 0, 50, 20), "open"))
        {
              csMain.StartLoadingProject(@"my_url");
        }
    }
}


public static class csMain 
{
    public static void StartLoadingProject(string lURL)
    {
        if (mySaveOpen == null)
            mySaveOpen = new csSaveAndOpen();
      
        mySaveOpen.OpenFile(lURL, XMLFileType.Project);
    }
}


public class csSaveAndOpen : MonoBehaviour
{
    public void OpenFile(String lURL, XMLFileType lType)
    {
        //The error is on next line
        StartCoroutine(DownloadFile(lURL, lType));
    }

    IEnumerator DownloadFile(String lURL, XMLFileType lType)
    {
       //...
    }
}

I can’t figure what the problem is.
The error message :

Thanks in advance for help

I found where was my problem :

Because i tried to instantiate myself csSaveAndOpen, i was unable to use StartCoroutine and such…

Thx anyway :smile:

Could you put an example of the syntax used for the AddComponent()? I am trying to reference one class from a different class and am getting that same warning about using the keyword ‘new’ and the error about null reference for StartCoroutine. I haven’t been able to find anything that shows how to do that using AddComponent(), so if you could help that would be wonderful. Thanks.