Problem with reflection in Unit/Integration tests

c#, reflection, unit-testing

Solution

The `bin/Debug` folder is not where the unit tests run. Visual Studio will copy the output of your unit test compilation to a `TestResults` folder (typically keeping the last five test runs, each with a timestamp embedded in the folder name) and run the unit tests there.

If you want the .DLL in that folder, either create a reference to the .DLL from your test project, or use the DeploymentItem attribute to make sure the item is copied to the test directory.

Problem

I´m dynamically creating an instance of a class with reflection and this works fine, except when trying to do this through unit testing - I´m using the MS testing framework. I get the familiar error of: "Could not load file or assembly 'Assy' or one of its dependencies. The system cannot find the file specified" I have copied the dll into the bin\debug bin of the Unit test project - is this not the correct place to put it? ``` string assyName = "Go.Data.SqlServer"; string typeName = "GoMolaMola.Data.SqlServer.DataProviderFactory"; Assembly assy = Assembly.Load( assyName ); object o = assy.CreateInstance( typeName ); ``` Any ideas? I'm new to unit testing and any help would be appreciated. Thanks

Original source