NLog.Mongo icon indicating copy to clipboard operation
NLog.Mongo copied to clipboard

Latest mongoDB Driver 2.0

Open matthiasjost opened this issue 9 years ago • 4 comments

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)

matthiasjost avatar Apr 03 '15 13:04 matthiasjost

Is it possible to have the web application project itself with a newer driver than the one your Target depends on?

matthiasjost avatar Apr 10 '15 07:04 matthiasjost

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.

cccsdh avatar May 07 '15 12:05 cccsdh

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.

matthiasjost avatar May 07 '15 14:05 matthiasjost

@pwelter34 Looks resolved, as this project is now using MongoDB.Driver ver. 2.7.0

snakefoot avatar Dec 17 '18 21:12 snakefoot