gpt4 book ai didi

asp.net-mvc-3 - 系统参数异常 : Duplicate type name within an assembly

转载 作者:行者123 更新时间:2023-12-02 20:52:20 25 4
gpt4 key购买 nike

我正在使用 EF 4.1 开发 ASP.Net MVC 3 Web 应用程序。从今天开始,我收到此错误:

System.ArgumentException:程序集中的类型名称重复

我不知道是什么原因造成的。执行查找时,它发生在我的存储库中:

public virtual T GetById(long id)
{
return dbset.Find(id);
}

这是堆栈跟踪:

[ArgumentException: Duplicate type name within an assembly.]
System.Reflection.Emit.ModuleBuilder.CheckTypeNameConflict(String strTypeName, TypeBuilder enclosingType) +9544354
System.Reflection.Emit.AssemblyBuilderData.CheckTypeNameConflict(String strTypeName, TypeBuilder enclosingType) +53
System.Reflection.Emit.TypeBuilder.Init(String fullname, TypeAttributes attr, Type parent, Type[] interfaces, Module module, PackingSize iPackingSize, Int32 iTypeSize, TypeBuilder enclosingType) +178
System.Reflection.Emit.ModuleBuilder.DefineType(String name, TypeAttributes attr, Type parent, Type[] interfaces) +118
System.Data.Objects.Internal.ProxyTypeBuilder.get_TypeBuilder() +299
System.Data.Objects.Internal.ProxyTypeBuilder.CreateType(ModuleBuilder moduleBuilder) +227
System.Data.Objects.Internal.EntityProxyFactory.BuildType(ModuleBuilder moduleBuilder, ClrEntityType ospaceEntityType) +63
System.Data.Objects.Internal.EntityProxyFactory.TryCreateProxyType(EntityType ospaceEntityType) +193
System.Data.Objects.Internal.EntityProxyFactory.GetProxyType(ClrEntityType ospaceEntityType) +104
System.Data.Common.Internal.Materialization.Translator.Visit(EntityColumnMap columnMap, TranslatorArg arg) +178
System.Data.Query.InternalTrees.EntityColumnMap.Accept(ColumnMapVisitorWithResults`2 visitor, TArgType arg) +16
System.Data.Common.Internal.Materialization.Translator.ProcessCollectionColumnMap(CollectionColumnMap columnMap, TranslatorArg arg, ColumnMap discriminatorColumnMap, Object discriminatorValue) +116
System.Data.Common.Internal.Materialization.Translator.Visit(SimpleCollectionColumnMap columnMap, TranslatorArg arg) +13
System.Data.Query.InternalTrees.SimpleCollectionColumnMap.Accept(ColumnMapVisitorWithResults`2 visitor, TArgType arg) +17
System.Data.Common.Internal.Materialization.Translator.TranslateColumnMap(QueryCacheManager queryCacheManager, ColumnMap columnMap, MetadataWorkspace workspace, SpanIndex spanIndex, MergeOption mergeOption, Boolean valueLayer) +314
System.Data.Common.Internal.Materialization.TypedShaperFactoryCreator`1.TypedCreate(QueryCacheManager cacheManager, ColumnMap columnMap, MetadataWorkspace metadata, SpanIndex spanInfo, MergeOption mergeOption, Boolean valueLayer) +64
System.Data.Common.Internal.Materialization.ShaperFactory.Create(Type elementType, QueryCacheManager cacheManager, ColumnMap columnMap, MetadataWorkspace metadata, SpanIndex spanInfo, MergeOption mergeOption, Boolean valueLayer) +185
System.Data.Objects.Internal.ObjectQueryExecutionPlan.Prepare(ObjectContext context, DbQueryCommandTree tree, Type elementType, MergeOption mergeOption, Span span, ReadOnlyCollection`1 compiledQueryParameters) +285
System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption) +696
System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +149
System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() +44
System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +184
System.Data.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__2(IEnumerable`1 sequence) +41
System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle(IEnumerable`1 query, Expression queryRoot) +59
System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute(Expression expression) +150
System.Linq.Queryable.SingleOrDefault(IQueryable`1 source) +265
System.Data.Entity.Internal.Linq.InternalSet`1.FindInStore(WrappedEntityKey key, String keyValuesParamName) +602
System.Data.Entity.Internal.Linq.InternalSet`1.Find(Object[] keyValues) +124
System.Data.Entity.DbSet`1.Find(Object[] keyValues) +12
XXXXXXXX.Data.Infrastructure.RepositoryBase`1.GetById(Int64 id) in C:\XXXXXXXX\XXXXXXXX\XXXXXXXX.Data\Infrastructure\RepositoryBase.cs:58
MatchesHorsConcours.Service.MatchService.GetMatch(Int32 id) in C:\XXXXXXXX\XXXXXXXX\XXXXXXXX.Service\XxxService.cs:55
XXXXXXXX.Controllers.XXXXXXXX.Edit(Int32 id) in C:\XXXXXXXX\XXXXXXXX\XXXXXXXX.Web\Controllers\XxxController.cs:130
lambda_method(Closure , ControllerBase , Object[] ) +101
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +208
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
System.Web.Mvc.Controller.ExecuteCore() +116
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8920029
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

这可能与我在其中复制外键的表有关。它的名称类似于 myKeyId,现在该表中有 myKey1Id 和 myKey2Id。我检查了代码中的所有位置,但找不到 myKeyId。

错误消息非常笼统,我不知道如何确定导致此错误的原因。欢迎任何建议。

最佳答案

我也遇到了同样的错误。

我重建了干净的解决方案并且它有效。

关于asp.net-mvc-3 - 系统参数异常 : Duplicate type name within an assembly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7328364/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com