You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

.NET 4.8 ASP.NET MVC项目调试IndexAttribute加载失败求助

调试.NET 4.8 ASP.NET MVC项目时的TypeLoadException问题排查

我在使用IIS Express调试基于.NET 4.8的ASP.NET MVC项目时遇到异常,具体错误信息如下:

[TypeLoadException: Could not load type 'System.ComponentModel.DataAnnotations.Schema.IndexAttribute' from assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.]
   System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) +0
   System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +195
   System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +196
   System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) +156
   System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +630
   System.Reflection.CustomAttribute.GetCustomAttributes(RuntimePropertyInfo property, RuntimeType caType) +106
   System.Attribute.InternalGetCustomAttributes(PropertyInfo element, Type type, Boolean inherit) +41
   System.Attribute.GetCustomAttribute(MemberInfo element, Type attributeType, Boolean inherit) +15
   System.Reflection.CustomAttributeExtensions.GetCustomAttribute(MemberInfo element, Boolean inherit) +56
   AutoMapper.Configuration.Conventions.<>c.<GetMatchingMemberInfo>b__2_0(MemberInfo sourceMember) +37
   System.Linq.WhereSelectListIterator`2.MoveNext() +121
   System.Linq.WhereEnumerableIterator`1.MoveNext() +259
   System.Linq.Buffer`1..ctor(IEnumerable`1 source) +215
   System.Linq.Enumerable.ToArray(IEnumerable`1 source) +51
   AutoMapper.Configuration.Conventions.SourceToDestinationNameMapperAttributesMember.GetMatchingMemberInfo(IGetTypeInfoMembers getTypeInfoMembers, TypeDetails typeInfo, Type destType, Type destMemberType, String nameToSearch) +451
   AutoMapper.Configuration.Conventions.ParentSourceToDestinationNameMapper.GetMatchingMemberInfo(TypeDetails typeInfo, Type destType, Type destMemberType, String nameToSearch) +164
   AutoMapper.Configuration.Conventions.DefaultMember.MapDestinationPropertyToSource(ProfileMap options, TypeDetails sourceType, Type destType, Type destMemberType, String nameToSearch, LinkedList`1 resolvers, IMemberConfiguration parent) +78
   AutoMapper.Configuration.Conventions.MemberConfiguration.MapDestinationPropertyToSource(ProfileMap options, TypeDetails sourceType, Type destType, Type destMemberType, String nameToSearch, LinkedList`1 resolvers) +181
   AutoMapper.<>c__DisplayClass1_0.<MapDestinationPropertyToSource>b__0(IMemberConfiguration _) +67
   System.Linq.Enumerable.Any(IEnumerable`1 source, Func`2 predicate) +182
   AutoMapper.TypeMapFactory.CreateTypeMap(Type sourceType, Type destinationType, ProfileMap options) +364
   AutoMapper.ProfileMap.BuildTypeMap(TypeMapRegistry typeMapRegistry, ITypeMapConfiguration config) +99
   AutoMapper.ProfileMap.Register(TypeMapRegistry typeMapRegistry) +243
   AutoMapper.MapperConfiguration.Seal() +279
   AutoMapper.MapperConfiguration..ctor(MapperConfigurationExpression configurationExpression) +1018
   AutoMapper.Mapper.Initialize(Action`1 config) +46
   Clubr.Web.LandingPage.App_Start.AutoMapperConfig.RegisterMappings() in E:\Farhad\Repositories\clbrr\Source\Clubr.Web.LandingPage\App_Start\AutoMapperConfig.cs:10
   Clubr.Web.LandingPage.Startup.Configuration(IAppBuilder app) in E:\Farhad\Repositories\clbrr\Source\Clubr.Web.LandingPage\Startup.cs:25

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +216
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +182
   Owin.Loader.<>c__DisplayClass18_1.<MakeDelegate>b__0(IAppBuilder builder) +93
   Owin.Loader.<>c__DisplayClass9_0.<LoadImplementation>b__0(IAppBuilder builder) +224
   Microsoft.Owin.Host.SystemWeb.OwinAppContext.Initialize(Action`1 startup) +897
   Microsoft.Owin.Host.SystemWeb.OwinBuilder.Build(Action`1 startup) +51
   Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +101
   System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +139
   Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +160
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +584
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +168
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +277
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +369

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +532
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +719

已尝试的操作:

  • 升级EntityFramework至新版本
  • 改用本地IIS调试

请问降级Visual Studio至旧版本是否可行?现寻求有效的解决办法。


内容的提问来源于stack exchange,提问作者Farhad Mousavi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 09:19:58