首页 > 解决方案 > TargetInvocationException - 对象引用未设置为对象的实例。对于自动映射器

问题描述

我经常在 Windows 事件查看器 - 应用程序错误日志中看到以下错误。这发生在 Amazon Windows Server 上。

Web 应用程序位于 ASP.net MVC 5 中。我最近更新了 NuGet 包以解决此错误,但错误仍然存​​在。

Event code: 3005 
Event message: An unhandled exception has occurred. 
Event sequence: 22 
Event occurrence: 9 
Event detail code: 0 

Application information: 
    Trust level: Full 
    Application Virtual Path: / 
    Application Path: WebApPath 
    Machine name: EC2AMAZ-TUK4T6L 

Process information: 
    Process ID: 9628 
    Process name: w3wp.exe 
    Account name: IIS APPPOOL\ AppPoolName 

Exception information: 
    Exception type: TargetInvocationException 
    Exception message: Exception has been thrown by the target of an invocation.
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeConstructorInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.FastCreateInstance(Type implType, Object[] arguments, ConstructorCandidate constructor)
   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstanceCore(ConstructorCandidate constructor, Object[] arguments, Type implType)

Object reference not set to an instance of an object.
   at AutoMapper.TypeMapFactory.<>c__DisplayClass3_0.<MapDestinationPropertyToSource>b__0(IMemberConfiguration _)
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
   at AutoMapper.TypeMapFactory.CreateTypeMap(Type sourceType, Type destinationType, IProfileConfiguration options, MemberList memberList)
   at AutoMapper.ConfigurationStore.<>c__DisplayClass80_0.<CreateTypeMap>b__0(TypePair tp)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at AutoMapper.ConfigurationStore.CreateMap[TSource,TDestination](String profileName, MemberList memberList)
   at AP.Web.Services.Services.CustInfoService..ctor(ICustInfoRepository repository)

Thread information: 
    Thread ID: 22 
    Thread account name: IIS APPPOOL\ AppPoolName 
    Is impersonating: False 
    Stack trace:    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeConstructorInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.FastCreateInstance(Type implType, Object[] arguments, ConstructorCandidate constructor)
   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstanceCore(ConstructorCandidate constructor, Object[] arguments, Type implType)


Custom event details:

无法确定为什么会出现此错误。对你的帮助表示感谢。

谢谢,

拉吉。

标签: iisasp.net-mvc-5automappercastle-windsor

解决方案


推荐阅读