4
目前我正在寫一個C#COM服務器,它將被C++客戶端使用。我想一定HRESULT返回到C++代碼時的具體例外,如以下如何將C#中的HRESULT返回到C++而不是拋出異常?
// C# COM Server Code
public void MyMethod()
{
try
{
//Some Processing
}
catch(CertainException e)
{
//I pass in my Own HResult int to the my Custom Exception
MyCustomException ex = new MyCustomException(unchecked((int)0xc00491fe));
throw ex;
}
}
//C++ Code
HRESULT hr = pMyComInstance->MyMethod();
的C#代碼被提升我想到的是,「HR」我從我的C得到++代碼是我分配到INT我的C#代碼,但是,而不是得到HRRESULT,我仍然得到了C++代碼中的異常。
我做錯了什麼?請幫忙..謝謝
嘗試拋出'COMException' – SLaks 2012-04-02 02:24:27
@SLaks謝謝你!它的工作原理應該拋出COMException – BloodroseWu 2012-04-02 03:06:16