異常內容 System.TypeLoadException HResult=0x80131522 Message=Method 'get_IsTraceEnabled' in type 'Abp.Castle.Logging.Log4Net.Log4NetLogger' from assembly ...
異常內容
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
。