System.NullReferenceException: Ссылка на объект не указывает на экземпляр объекта. При попытке подключится к SIP серверу

Я использую библиотеку Ozeki VoIP SIP SDK для того, чтобы подключиться к SIP серверу и отслеживать INVITE запросы на аккаунт. Делаю всё как написано в мануале библиотеки, но в строке:

phoneLine = softphone.CreatePhoneLine(sipAccount: account); // в методе RegisterAccount()

Появляется ошибка:

System.NullReferenceException: Ссылка на объект не указывает на экземпляр объекта.

Вот код программы:

using System;
using System.Windows.Forms;
using System.Diagnostics;
using Ozeki.VoIP;
using Ozeki.VoIP.SDK;

namespace SIPCallInf {
public class Program
{     
    
    public bool authStatus = false; // agent authorization status

    static ISoftPhone softphone;   // softphone object
    static IPhoneLine phoneLine;   // phoneline object
    static IPhoneCall call;
   


    private static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());

        softphone = SoftPhoneFactory.CreateSoftPhone(5000, 10000);

        
    }


    public void Authorization(string userName, string password) 
    {
        var registrationRequired = true;
        var domainHost = "some_server_domain.com";
        var domainPort = 5060;


        SIPAccount account = new SIPAccount(registrationRequired, userName, userName, userName, password, domainHost, domainPort);
        RegisterAccount(account);

    }

    public void RegisterAccount(SIPAccount account)
    {
        try
        {
            phoneLine = softphone.CreatePhoneLine(sipAccount: account);
            phoneLine.RegistrationStateChanged += line_RegStateChanged;
            softphone.IncomingCall += softphone_IncomingCall;
            softphone.RegisterPhoneLine(phoneLine);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error during SIP registration: " + ex);
        }
    }

    private void line_RegStateChanged(object sender, RegistrationStateChangedArgs e)
    {
        if (e.State == RegState.NotRegistered || e.State == RegState.Error)
            Console.WriteLine("Registration failed!");

        if (e.State == RegState.RegistrationSucceeded) 
        {
            Console.WriteLine("Registration succeeded - Online!");
            authStatus = true;
        }
            
            
    }

    static void softphone_IncomingCall(object sender, VoIPEventArgs<IPhoneCall> e)
    {
        call = e.Item;
        call.CallStateChanged += call_CallStateChanged;
        Debug.Print(call.DialInfo.ToString());
    }

    static void call_CallStateChanged(object sender, CallStateChangedArgs e)
    {
        Console.WriteLine("Call state: {0}.", e.State);
    }
}   }

Ссылка на первоисточник кода: https://voip-sip-sdk.com/p_7092-how-to-accept-incoming-call-using-csharp.html


Ответы (0 шт):