Loading

Abp.Castle.Log4Net : Method 'get_IsTraceEnabled' does not have an implementation

异常内容

System.TypeLoadException
  HResult=0x80131522
  Message=Method 'get_IsTraceEnabled' in type 'Abp.Castle.Logging.Log4Net.Log4NetLogger' 
  from assembly 'Abp.Castle.Log4Net, Version=4.5.0.0, Culture=neutral, PublicKeyToken=null' 
  does not have an implementation.
  Source=Abp.Castle.Log4Net
  StackTrace:
   at Abp.Castle.Logging.Log4Net.Log4NetLoggerFactory.Create(String name)
   at Castle.Facilities.Logging.LoggingFacility.RegisterDefaultILogger(ILoggerFactory factory)
   at Castle.Facilities.Logging.LoggingFacility.Init()
   at Castle.MicroKernel.DefaultKernel.AddFacility(String key, IFacility facility)
   at Castle.Windsor.WindsorContainer.AddFacility[T](Action`1 onCreate)

解决思路

因为GitHub上有ABP的源码:aspnetboilerplate,准备看源码,这个方法不建议推荐,比较花时间,很可能费力不讨好。但是搞清楚之后肯定有助于加深对ABP的理解。为了最快解决问题,从想想bug怎么出现倒推解决办法。我是因为更新了解决方案的nuget包。这就好说了。解决办法:试着降级nuget包。

我是将 Abp.Castle.Log4Net 从4.3升级到了4.5 。一步到位,降级到4.3 ,信心满满的debug,异常依旧。我想或许会有人提Issue,没有我就自己提Issue。搜索Issue:https://github.com/aspnetboilerplate/aspnetboilerplate/search?q=get_IsTraceEnabled&type=Issues ,搜索结果显示已经有人提了 Issue。 Issue 4445:: System.TypeLoadException: Method 'get_IsTraceEnabled'
该Issue的解决方案是同时降级 Abp.Castle.Log4Net 和 Castle.Core
在这里插入图片描述
既然单单降级Abp.Castle.Log4Net不行,私以为问题在Castle.Core。尝试将Abp.Castle.Log4Net包依然升级到4.5,只降级Castle.Core到4.3.1 。速度debug,bug解决。看来问题是因为Abp.Castle.Log4Net对应的应该是Castle.Core 4.3.1。想要搞明白真正的问题得去看Castle的源码了。

一句话总结解决方案:将Castle.Core降级到4.3.1

posted @ 2019-04-25 17:58  repeatedly  阅读(916)  评论(0编辑  收藏  举报