Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mstest - unable to get type error

I'm getting the following error when using "run all tests in solution" or "run checked tests", but if I use "debug checked tests" they run fine.

Unable to get type TestDataLayer.TestPatientDAO, TestDataLayer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. Error: System.TypeLoadException: Could not load type 'DomainLayer.BaseEntity' from assembly 'DomainLayer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

DomainLayer.BaseEntity is an abstract class.

Removing and adding the reference to DomainLayer again didn't help.

Unloading and loading TestDataLayer or DomainLayer didn't help.

edit: removing and adding CodeCoverage solved the problem (wtf)

like image 887
myAces Avatar asked Feb 25 '23 10:02

myAces


1 Answers

Adding as an answer to help others discover a possible solution to this problem:

As per myAces, I was getting a TypeLoadException when running MSTest unit tests from within Visual studio 2010. Debugging the tests would work flawlessly, Running the tests via the Resharper tests would pass flawlessly.

Like myAces, the Code Coverage was the problem. To fix I performed the following:

Test Menu -> Edit Test Settings -> Local

Data and Dianostics -> Untick the Code coverage option -> Apply & Close

Then reapplied Code Coverage to required assemblies and everything works fine.

like image 128
Ash Avatar answered Mar 05 '23 05:03

Ash