NLog.Mongo
NLog.Mongo copied to clipboard
Latest mongoDB Driver 2.0
nLog does not work when I upgrade my project to the latest mongoDB Driver:
---> 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)
Is it possible to have the web application project itself with a newer driver than the one your Target depends on?
The issue is that the new Mongodb driver is a major update with breaking changes. Anything based on the old driver is going to be broken when upgrading to the new driver. You might check out the nuget package: https://www.nuget.org/packages/NLog.MongoDB20/, which is a port of https://github.com/Logrythmik/NLog.MongoDB to utilize the new MongoDB driver 2.0 api.
Thank you. For me it looks like there are not many contributions in this project. We are going to use Serilog with their offical mongoDB target.
@pwelter34 Looks resolved, as this project is now using MongoDB.Driver ver. 2.7.0