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包。git

我是將 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的源碼了。github

一句話總結解決方案:將Castle.Core降級到4.3.1debug

相關文章
相關標籤/搜索