C# – Running C++ code through NUnit

appdomainc++nunit

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

Best Solution

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.