用c++做了一个com组件,其中要抛出异常:
void throw_some_exception
{
throw "some exception";
}
但是c#中捕捉到的异常信息e.Message只是“外部组件错误”,而不能显示"some exception"。
谁知道怎样才能得到具体的异常信息?

解决方案 »

  1.   

    In COM, a common way to return success or failure is to return an HRESULT and have an out parameter ed as "retval" in MIDL for the real return value of the method. In C# (and the .NET Framework), the standard way to indicate an error has occurred is to throw an exception.By default, the .NET Framework provides an automatic mapping between the two styles of exception handling for COM interface methods called by the .NET Framework. The return value changes to the signature of the parameter ed retval (void if the method has no parameter ed as retval). 
    The parameter ed as retval is left off of the argument list of the method. 
    Any non-success return value will cause a System.COMException exception to be thrown.
      

  2.   

    不太明白你的意思。
    事实是,即使不用com,直接导出dll供c#调用,
    自己抛出的异常也不能捕捉