我有一个使用pjsua2(SIP协议)的winforms应用程序winforms是一个带有框架4.7的64位应用程序。 pjsua2是一个x86程序集。当我销毁PJSUA2实例时,它会引发异常。奇怪的是,它没有被放置代码的try / catch捕获。我不明白为什么?
有没有办法抑制此异常?
/// <summary>
/// brief UserAgent::UserAgentStop
/// </summary>
public void UserAgentStop()
{
Console.Write("Stopping endpoint");
///this code destroys the SIP connection and clears the relevant objects
try
{
ep.mediaRemove(play_med);
ep.mediaRemove(cap_med);
//dispose all sip objects, so they can be garbage collected
ep.libStopWorkerThreads();
ep.libDestroy();
ep.Dispose();
//// Send new state
forwardNewRegState(-2);
//force garbage collection of all disposed objects
GC.Collect();
}
catch (Exception ex)
{
Logging.LogAppender.AppendToLog("Error UN-registering SIP connection: " + ex.Message);
}
}