System.InvalidCastException
在一些朋友的帮助下使用 MVC 2 广告时,我认为所有错误都已修复,直到我遇到了这个巨大的错误(就我个人而言,这是我造成的最大的异常解释。
错误消息
[A]GodsCreationTaxidermy.Data.EFUnitOfWork 不能投射到 [B]GodsCreationTaxidermy.Data.EFUnitOfWork。 A型起源于 '众神创造标本剥制术.核心, 版本=1.0.0.0,文化=中立, 上下文中的 PublicKeyToken=null' 位置的“默认” 'C:\用户\理查德 L. 麦卡琴\应用程序数据\本地\临时\临时 网络平台 文件\根\3d450750\bcfb1c91\程序集\dl3\200754f0\6a7f303e_1418cc01\GodsCreationTaxidermy.Core.DLL'。 B型起源于 'GodsCreation动物标本剥制术.Data, 版本=1.0.0.0,文化=中立, 上下文中的 PublicKeyToken=null' 位置的“默认” 'C:\用户\理查德 L. 麦卡琴\AppData\Local\Temp\Temporary 网络平台 文件\根\3d450750\bcfb1c91\程序集\dl3\5d86cf1a\5d1f256f_0118cc01\GodsCreationTaxidermy.Data.DLL'。
它出现在这一行(在 GenericRepository 中):
public UoW GetCurrentUnitOfWork<UoW>() where UoW : IUnitOfWork
{
return (UoW)UnitOfWork.Current; //<< error happens here
}
正如建议的那样,我从临时目录中删除了所有 ASP.NET 文件,并且它更改了注释。
我很确定这个方法是唯一一个调用 that 的方法,这反过来又触发了错误
private ObjectContext Context
{
get
{
if (_context == null)
{
return _context = GetCurrentUnitOfWork<GodsCreationTaxidermy.Data.EFUnitOfWork>().Context;
}
return _context;
}
}
那么,有人遇到过类似的事情吗?
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 caused.
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您最近重命名了类库吗?看起来您在两个不同的类中有两个版本的 EFUnitOfWork; GodsCreationTaxidermy.Core 和 GodsCreationTaxidermy.Data,这可能是问题所在。
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.
不知何故,我有我的工作单元和存储库的副本,所以这是所有内容的 2 个,而 MVC 不知道该怎么做。
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.