views:

343

answers:

2

Hello, I have tried to use NUnit to test C# code the is already connected to C++ code (without the NUnit the application work perfectly).

In my test I run the main function through AppDomain.CurrentDomain.ExecuteAssembly(..), However when the C# code tries to "communicate" with the C++ it throws an exception and the test crashes. The exception is System.Reflection.TargetInvocationException if anyone has and idea why its happen it will be very very helpful... Thanks, Naama

+1  A: 

Your suspicions are correct it is being through during the constructor, the constructor in c# is trying to create an object (it is already wrapped and work perfect when the application is running normally) that is written in c++ and in c++ in the constructor of the object the exception is thrown. However the application is very complex but if it necessary for clarification I will write a demo application that symbol the real one.

"Your" being mine?
strager
+1  A: 

It is likely that an exception is being thrown in your C++ code, in the constructor of the class. Check to make sure you're handling exceptions properly and that you're giving the proper information to the constructor so exceptions aren't thrown.

strager