NLog.Mongo 和最新的 mongoDB C# 驱动程序不工作
NLog.Mongo and latest mongoDB C# driver not working
当我将我的项目升级到最新的 mongoDB 驱动程序时,nLog 不起作用:
---> 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 驱动程序版本。
您可以将程序集绑定添加到您的 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>
当我将我的项目升级到最新的 mongoDB 驱动程序时,nLog 不起作用:
---> 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 驱动程序版本。
您可以将程序集绑定添加到您的 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>