Working with MVC 2 ad with the help of some friends I thought all the errors were fixed, until I ran into this behemoth of an error (personally the largest exception explanation I've ever c开发者_Go百科aused.
Error Message
[A]GodsCreationTaxidermy.Data.EFUnitOfWork cannot be cast to [B]GodsCreationTaxidermy.Data.EFUnitOfWork. Type A originates from 'GodsCreationTaxidermy.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\Users\Richard L. McCutchen\AppData\Local\Temp\Temporary ASP.NET Files\root\3d450750\bcfb1c91\assembly\dl3\200754f0\6a7f303e_1418cc01\GodsCreationTaxidermy.Core.DLL'. Type B originates from 'GodsCreationTaxidermy.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\Users\Richard L. McCutchen\AppData\Local\Temp\Temporary ASP.NET Files\root\3d450750\bcfb1c91\assembly\dl3\5d86cf1a\5d1f256f_0118cc01\GodsCreationTaxidermy.Data.DLL'.
And it comes on this line (in GenericRepository):
public UoW GetCurrentUnitOfWork<UoW>() where UoW : IUnitOfWork
{
return (UoW)UnitOfWork.Current; //<< error happens here
}
As was suggested I deleted all the ASP.NET files from the temp directory and it changed noting.
I'm pretty sure that this method is the only one calling that , which in turn triggers the error
private ObjectContext Context
{
get
{
if (_context == null)
{
return _context = GetCurrentUnitOfWork<GodsCreationTaxidermy.Data.EFUnitOfWork>().Context;
}
return _context;
}
}
So, has anyone ran into something similar they can help with?
Have you recently renamed a class library? It looks like you have two versions of EFUnitOfWork in two different classes; GodsCreationTaxidermy.Core and GodsCreationTaxidermy.Data, this may be the issue.
Somehow I had a copy of my unit of work and repository, so that was 2 of everything and MVC didn't know what to do.
精彩评论