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)
It logs nothing. I am using a mongoDB target for nLog. I already posted an issue (https://github.com/loresoft/NLog.Mongo/issues/7). But maybe there is a way to solve it on my own.
Any suggestions?
The target works with official mongoDB driver versions before 1.9.
You can add an Assembly binding to your 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>
Related
Getting a runtime exception when using MapHttpRoute extension method
Library: Microsoft.AspNet.WebApi (5.2.4), System.Web.Http (5.2.4)
Exception:
System.MissingMethodException
HResult=0x80131513
Message=Method not found: 'System.Web.Http.Routing.IHttpRoute System.Web.Http.HttpRouteCollectionExtensions.MapHttpRoute(System.Web.Http.HttpRouteCollection, System.String, System.String, System.Object, System.Object, System.Net.Http.HttpMessageHandler)'.
Web.config dependent assembly mapping is also present
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
</dependentAssembly>
I have tried re-installing the Microsoft.AspNet.WebApi library but to no avail.
I keep receiving following error:
log4net:ERROR Could not create Appender [AsyncLog4NetAppender] of type [Log4Net.Async.ParallelForwardingAppender]. Reported error follows.
System.TypeLoadException: Could not load type [Log4Net.Async.ParallelForwardingAppender]. Tried assembly [log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a] and all loaded assemblies
at log4net.Util.SystemInfo.GetTypeFromString(Assembly relativeAssembly, String typeName, Boolean throwOnError, Boolean ignoreCase)
at log4net.Util.SystemInfo.GetTypeFromString(String typeName, Boolean throwOnError, Boolean ignoreCase)
at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement appenderElement)
log4net:ERROR Appender named [AsyncLog4NetAppender] not found.
Packages config
<package id="log4net" version="2.0.8" targetFramework="net451" />
<package id="Log4Net.Async" version="2.0.4" targetFramework="net451" />
Web config
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.8.0" newVersion="2.0.8.0"/>
</dependentAssembly>
When I remove the log4net.async nuget package and add it again it works. But after some time I get this error again.
You (probably) need to add the assembly name to your appender reference.
<appender name="AsyncLog4NetAppender" type="Log4Net.Async.ParallelForwardingAppender,Log4Net.Async">
Note the part after the comma, Log4Net.Async.
Adding the name of the reference assembly should tell .Net how to find the class in the appropriate assembly.
I have an ASP.NET 4.5.2 application that loads the Microsoft.Azure.ActiveDirectory.GraphClient library. When it tries to connect, the following error occurs:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Net, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
File Name: "System.Net, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"
bei System.Data.Services.Client.UriResolver.ConvertToAbsoluteUri(Uri baseUri)
bei System.Data.Services.Client.UriResolver.ConvertToAbsoluteAndValidateBaseUri(Uri& baseUri, String parameterName)
bei System.Data.Services.Client.DataServiceContext..ctor(Uri serviceRoot, DataServiceProtocolVersion maxProtocolVersion, ClientEdmModel model)
bei Microsoft.Azure.ActiveDirectory.GraphClient.Extensions.DataServiceContextWrapper..ctor(Uri serviceRoot, DataServiceProtocolVersion maxProtocolVersion, Func`1 accessTokenGetter, IEnumerable`1 customTypeMappings)
bei Microsoft.Azure.ActiveDirectory.GraphClient.ActiveDirectoryClient..ctor(Uri serviceRoot, Func`1 accessTokenGetter,...
I have added a binding redirect to my web.config already:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net" publicKeyToken="7cec85d7bea7798e" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.5.0" newVersion="4.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
But the problem persists. What is wrong here?
I just updated to the latest ASP.NET MVC and I am getting:
Method not found: 'System.Web.Routing.RouteValueDictionary
System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object)'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.MissingMethodException: Method not
found: 'System.Web.Routing.RouteValueDictionary
System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object)'.
Source Error:
Line 12: public static void RegisterRoutes(RouteCollection routes)
Line 13: {
Line 14: routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
Line 15:
Line 16: //routes.MapRoute(
Source File: C:\ProjectX\App_Start\RouteConfig.cs Line: 14
Stack Trace:
[MissingMethodException: Method not found: 'System.Web.Routing.RouteValueDictionary
System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object)'.]
System.Web.Mvc.RouteCollectionExtensions.CreateRouteValueDictionaryUncached(Object values) +0
System.Web.Mvc.RouteCollectionExtensions.IgnoreRoute(RouteCollection routes, String url,
Object constraints) +94
System.Web.Mvc.RouteCollectionExtensions.IgnoreRoute(RouteCollection routes, String url) +7
COP.RouteConfig.RegisterRoutes(RouteCollection routes) in C:\ProjectX\App_Start\RouteConfig.cs:14
COP.MvcApplication.Application_Start() in C:\ProjectX\Global.asax.cs:27
[HttpException (0x80004005): Method not found: 'System.Web.Routing.RouteValueDictionary
System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object)'.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context,
HttpApplication app) +9935033
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext
context, MethodInfo[] handlers) +118
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers,
IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext,
HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): Method not found: 'System.Web.Routing.RouteValueDictionary
System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object)'.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9913572
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,
HttpContext context) +254
I have followed this guide: http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2
I even 2nd passed the DLL list in the document as a check list to make sure I didn't miss anything. However, I am apparently missing something.
Try revert you Web.config and packages.config to previous workable version and downgrade the NuGet packs...
This is likely because your MVC has been upgraded while some relative DLL are still the old and incompatible versions...
I met a similar problem and I solved it by modifying Web.config under project folder as below:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930"
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Simular issue:
WCF Data Service deployment issues
The server encountered an error processing the request. The exception
message is 'The type initializer for
'System.Data.Services.Providers.ResourceType' threw an exception.'.
See server logs for more details. The exception stack trace is:
at
System.Data.Services.Providers.ResourceType.get_PrimitiveResourceTypeMap()
at
System.Data.Services.Providers.ObjectContextServiceProvider.PopulateMetadata(IDictionary2
knownTypes, IDictionary2 childTypes, IDictionary2 entitySets) at
System.Data.Services.Providers.BaseServiceProvider.LoadMetadata() at
System.Data.Services.DataService1.CreateMetadataAndQueryProviders(IDataServiceMetadataProvider&
metadataProviderInstance, IDataServiceQueryProvider&
queryProviderInstance, BaseServiceProvider& builtInProvider, Object&
dataSourceInstance) at
System.Data.Services.DataService1.CreateProvider() at
System.Data.Services.DataService1.HandleRequest() at
System.Data.Services.DataService`1.ProcessRequestForMessage(Stream
messageBody) at SyncInvokeProcessRequestForMessage(Object , Object[] ,
Object[] ) at
System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object
instance, Object[] inputs, Object[]& outputs) at
System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&
rpc) at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&
rpc) at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&
rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean
isOperationContextSet)
We are using the follow ddl
Microsoft.Data.Edm.dll 5.2.0.51212
Microsoft.Data.OData.dll 5.2.0.51212
System.Spatial.dll 5.2.0.51212
We have checked the files on the server, there all there.
The versions are the same
Still have no clue what it could be... Idea's?
Thanks !
Solved...
First install:
Install-Package Microsoft.Data.Services -Version 5.2.0
In your web.config add:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Services" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.2.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
And last, Remove all unnessary information in your connecting from metadata so you will end up like this:
<add name="MobileDataPlatformEntities" connectionString="metadata=res://*/; etc...