我有一个使用 pjsua2(一种 SIP 协议)的 winforms 应用程序 winforms 是一个 64 位应用程序,框架为 4.7。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);
}
}