KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
We have a large .NET solution with both C# and C++/CLI projects which reference each other. We also have several unit testing projects. We've recently upgraded from Visual Studio 2010 & .NET 4.0 to Visual Studio 4.5 & .NET 4.5, and now when we try to run the unit tests, there seem to be a problem loading some of the DLLs during the test. The problem appears to happen because unit testing is performed on a separate AppDomain. The unit testing process (for example nunit-agent.exe) creates a new AppDomain with AppBase set to the test project's location, but according the Fusion Log, some of the DLLs are loaded with nunit's executable's directory as the AppBase instead of the AppDomain's AppBase. I've managed to reproduce the problem with a simpler scenario, which creates a new AppDomain and tries to run the test there. Here's how it looks (I changed the names of the unit test classes, methods and the location of the dll to protect the innocent): class Program { static void Main(string[] args) { var setup = new AppDomainSetup { ApplicationBase = "C:\\DirectoryOfMyUnitTestDll\\" }; AppDomain domain = AppDomain.CreateDomain("MyDomain", null, setup); ObjectHandle handle = Activator.CreateInstanceFrom(domain, typeof(TestRunner).Assembly.CodeBase, typeof(TestRunner).FullName); TestRunner runner = (TestRunner)handle.Unwrap(); runner.Run(); AppDomain.Unload(domain); } } public class TestRunner : MarshalByRefObject { public void Run() { try { HtmlTransformerUnitTest test = new HtmlTransformerUnitTest(); test.SetUp(); test.Transform_HttpEquiv_Refresh_Timeout(); } catch (Exception e) { Console.WriteLine(e); } } } This is the exception I get when trying to execute the unit test. As you can see, the problem happens the the C++ dll
Tags (comma-separated)
Save Edits
Cancel