In my DataAccess
project I have the code:
using (TandAEntities dataContext = new TandAEntities())
{
// Some code
}
This gives no error and works fine.
But in my Unit Test project, I have that same code, but the compiler gives an error; type used in a using statement must be implicitly convertible to 'System.IDisposable'
I checked the definition by pressing F12
, and it does indeed implement IDisposable
, and has a dispose method.
Am I perhaps missing some references?
Most likely answer in linked duplicate - missing using System.Data.Linq
.
Other options: you have stale DLLs somewhere (i.e. installed in the GAC).
If you can't easily find stale DLL by just looking around and checking GAC - change code to something that uses this type but compiles and debug the test. Check Debug->Windows->Modules for location of the assembly with this type that is actually used.