我面临以下问题
COM object that has been separated from its underlying RCW cannot be used.'
System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.
at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
at Microsoft.Office.Interop.Outlook._MailItem.get_Subject()
以下代码:
var mail = inspectorWrapper.MailItem;
showcaseModel.Subject = mail?.Subject;
showcaseModel.Title = mail?.Subject;
我怎样才能避免这种异常?Marshal.ReleaseComObject(mail)
我应该用;释放邮件对象吗 ??