C#中的COM异常? [英] COM exceptions in C#?

查看:75
本文介绍了C#中的COM异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何在C#中捕获COM异常(IErrorInfo)?什么应该在里面

catch()?


一个例子:


试试

{

....

}

catch(这里有什么?)

{

....

}


How can I catch COM exceptions (IErrorInfo) in C#? What should be inside
catch()?

An example:

try
{
....
}
catch(What goes here?)
{
....
}

推荐答案

查看MSDN网站上的COMException:

http://msdn.microsoft.com/library/de...ClassTopic.asp

但是一个简单的例子:


试试

{

...

...

}

catch(System.Runtime.InteropServices.COMException exn)

{


}

HTH


Ollie Riches

Petar Popara <我的***** @ mail.net>在消息新闻中写道:%2 **************** @ TK2MSFTNGP09.phx.gbl ...
check out the COMException on the MSDN website:

http://msdn.microsoft.com/library/de...ClassTopic.asp
but a simple example:

try
{
...
...
}
catch(System.Runtime.InteropServices.COMException exn)
{

}
HTH

Ollie Riches
"Petar Popara" <my*****@mail.net> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl...

如何捕获COM异常(IErrorInfo)在C#中?什么应该在里面
catch()?

一个例子:

尝试
{
...
}
catch(这里有什么?)
{
...
}

How can I catch COM exceptions (IErrorInfo) in C#? What should be inside
catch()?

An example:

try
{
...
}
catch(What goes here?)
{
...
}



查看MSDN网站上的COMException
check out the COMException on the MSDN website



谢谢。我已经尝试了它并且它捕获了异常。


唯一的问题是我得到了未指定的错误 (e.Message())insead of

错误说明我在我的(VC ++ 6)COM对象中设置了。为什么?



Thank you. I''ve tried that and it catches the exception.

The only problem is that I got "Unspecified error" (e.Message()) insead of
error description I have set in my (VC++ 6) COM object. Why?


是否存在内部异常?


Ollie Riches

" Petar Popara" <我的***** @ mail.net>在消息中写道

news:u
is there an inner exception at all?

Ollie Riches
"Petar Popara" <my*****@mail.net> wrote in message
news:u


这篇关于C#中的COM异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆