HowTo throw custom C++ Exception and catch it in C# ?

I need to throw a custom exception in C++ DLL and catch it for further processing in C# code using this DLL. I need to pass a simple STRUCT having few unsigned int member variables. How to manage that?
Of course, I have access to both source codes, C++ and C#, as well...
LVL 1
darkriserAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jens FiedererTest Developer/ValidatorCommented:
Just catching an exception from UNMANAGED code, you are going to lose information.

Here
    http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/0624f3b3-5244-4cb8-be9c-29d464975d20/
they show (at the bottom) how to generate a wrapper that translates an exception (in their case, a string exception, but the unsigned would be similar).
darkriserAuthor Commented:
thanks...
but this hint requires compilation using /clr option.
this is something I need to avoid.
unfortunately...
Jens FiedererTest Developer/ValidatorCommented:
Remember this is for linking the wrapper assembly (with your original dll), not the compilation of your DLL itself.

Another option is to save the information inside your DLL, and provide a function or functions to retrieve it.
That way, when you call originally, you get a nondescript exception (exception thrown inside external component), but your exception handling can go back to the DLL to find out more using normal function mechanisms.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
darkriserAuthor Commented:
This is not the answer for my question but this is exactly how to solve my problem:-)
Thanks for those ideas...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.