Item 62 of Sutter and Alexandrescu's book "C++ Coding Standards" is "Don’t allow exceptions to propagate across module boundaries." Should we follow the same rule in C++/CLI?
+2
A:
You'll want to follow the standard guidance for exception handling in .NET, provided you're working on the managed side.
When working on the native side of C++/CLI, it's a good idea to follow standard C++ guidance, which includes trying to prevent exceptions from crossing module boundaries.
Reed Copsey
2009-12-02 18:06:16
Can you give a precise definition for what "working on the [managed/native] side" means in the context of the original question?
Jet
2009-12-02 18:36:49
Well, when you're using C++/CLI, you can be writing code that will be executed using the CLR (managed), or that is native, compiled code. The nice thing about C++/CLI is that the two can be mixed in a single exe or dll file. When you're writing managed code (ref class ..., etc), you're basically using C++ to write .NET code. In this case, follow .NET conventions. If you're doing standard C++ in a C++/CLI project, you'll want to follow C++ conventions.
Reed Copsey
2009-12-02 18:51:43
A:
As long as you're .NET on both sides of the module boundary, exception propagation is safe--that's one of the points of using .NET.
DrPizza
2009-12-02 18:25:06