2015-04-07 51 views
0

當我在我的項目升級到最新的MongoDB驅動n日誌不起作用:NLog.Mongo和最新的MongoDB C#驅動程序不能正常工作

---> System.TypeInitializationException: The type initializer for 'NLog.Mongo.MongoTarget' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'MongoDB.Driver, Version=1.9.2.235, Culture=neutral, PublicKeyToken=f686731cfb9cc103' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) 
at NLog.Mongo.MongoTarget..cctor() 
--- End of inner exception stack trace --- 
at NLog.Mongo.MongoTarget..ctor() 
--- End of inner exception stack trace --- 
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) 
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) 
at System.Reflection.ConstructorInfo.Invoke(Object[] parameters) 
at NLog.Internal.FactoryHelper.CreateInstance(Type t) 

它記錄什麼。我正在爲nLog使用mongoDB目標。我已經發布了一個問題(https://github.com/loresoft/NLog.Mongo/issues/7)。但也許有一種方法可以自行解決。

有什麼建議嗎?

該目標與1.9以前的官方mongoDB驅動程序版本一起使用。

回答

3

您可以添加一個集綁定到你的web.config

<runtime> 
     <dependentAssembly> 
     <assemblyIdentity name="MongoDB.Driver" publicKeyToken="f686731cfb9cc103" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-1.10.0.62" newVersion="1.10.0.62" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="MongoDB.Bson" publicKeyToken="f686731cfb9cc103" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-1.10.0.62" newVersion="1.10.0.62" /> 
     </dependentAssembly> 

    </runtime> 
+0

這是在web.config中手動執行,這可以通過GUI – Matthias

+0

Web.config進行做....... –