我正試圖製作一個程序來打開新的Outlook 2013消息。 我已經引用了Microsoft.Office.Interop.Outlook 15.0.0.0。發佈模式下的Outlook互操作異常(E_NOINTERFACE)
在調試模式下運行一切工作正常,但在發行模式與異常崩潰:
Unable to cast COM object of type 'Microsoft.Office.Interop.Outlook.ApplicationClass' to interface type 'Microsoft.Office.Interop.Outlook._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063001-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
代碼:
var _Outlook = new MSOutlook.Application();
var _MailItem = _Outlook.CreateItem(MSOutlook.OlItemType.olMailItem) as MSOutlook.MailItem;
var _Recip = _MailItem.Recipients.Add("[email protected]");
Recip.Type = (int)MSOutlook.OlMailRecipientType.olTo;
_MailItem.Recipients.ResolveAll();
_MailItem.Subject = "xxx";
_MailItem.Display(false);
其中MSOutlook = Microsoft.Office.Interop.Outlook命名空間。
我正在使用.NET Framework 4.5和Outlook 2013.
Release模式對此有何影響?奇怪的調試模式工作正常..
我將不勝感激任何想法如何解決它。謝謝!
我已經嘗試過的那一個,但可惜的是沒有sucess :( – dontbyteme