Mixed client and .NET library error handling.

We have a .NET library that exposes COM. Clients may be C#, or legacy VB6 code (hence the COM support). At runtime we do not know whether the client is VB6 or .NET.

The question is how to do error handling. .NET clients can handle exceptions but VB6 uses different error handling. How can we transparently provide suitable error handling for both contingencies. We need VB6 "On Error" type handling to work and we need .NET try catch to work. Note we do not always have control over the client code.

Do we convert all raised exceptions to COM exceptions? Thanks for any help here.


My suggestion is in your .NET library just throw any errors and let the consuming code handle it:

Try
   code ...
Catch
   Throw
End Try

If COM catches the throw it should interpret it and same goes for .NET...

链接地址: http://www.djcxy.com/p/51132.html

上一篇: 如何强制C#.net应用程序在Windows中只运行一个实例?

下一篇: 混合客户端和.NET库错误处理。