Mike Luken
Mike Luken

Reputation: 525

Can't find System.Diagnostics.EventLog Version=6.0.0.0 on .NET CORE 6

I migrated a web application from .NET CORE 5 to .NET CORE 6. When the application starts up, I am getting an error message in the Windows Event viewer indicating that it can't find System.Diagnostics.EventLog Version=6.0.0.0...

Full stack:

Application: w3wp.exe
CoreCLR Version: 6.0.21.52210
.NET Version: 6.0.0
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException: Could not load file or assembly 'System.Diagnostics.EventLog, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
File name: 'System.Diagnostics.EventLog, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   at Microsoft.Extensions.Logging.EventLog.EventLogSettings.CreateDefaultEventLog
   at Microsoft.Extensions.Logging.EventLog.EventLogSettings.get_EventLog
   at Microsoft.Extensions.Logging.EventLog.EventLogLogger..ctor(String name, EventLogSettings settings, IExternalScopeProvider externalScopeProvider)
   at Microsoft.Extensions.Logging.EventLog.EventLogLoggerProvider.CreateLogger(String name)
   at Microsoft.Extensions.Logging.LoggerFactory.CreateLoggers(String categoryName)
   at Microsoft.Extensions.Logging.LoggerFactory.CreateLogger(String categoryName)
   at Microsoft.Extensions.Logging.Logger`1..ctor(ILoggerFactory factory)
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.Extensions.Hosting.HostBuilder.<CreateServiceProvider>b__28_2(IServiceProvider _)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.Extensions.Hosting.HostBuilder.Build()
   at MyApp.Web.Program.Main(String[] args) in F:\MyApp\web\MyAppWeb\Program.cs:line 16

I even tried adding System.Diagnostics.EventLog as a package from nuget thinking maybe that would work, but it didn't...

Running:

OS: Windows 10 build 19044.1348
IIS: 10.0.19041.1

I also added this in my app.config to try to force an older version:

<runtime>
    <assemblyBinding>
        <dependentAssembly>
            <assemblyIdentity name="System.Diagnostics.EventLog"
                  publicKeyToken="cc7b13ffcd2ddd51"
                  culture="neutral" />
            <bindingRedirect oldVersion="6.0.0.0" newVersion="5.0.1.0" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>

It still gives the same error, trying to find 6.0.0.0.

Here are all my packages installed:

System.Diagnostics.EventLog         {6.0.0}                                  
System.Drawing.Common               {6.0.0}                                  
Microsoft.Extensions.Logging.Abs... {6.0.0}                                  
Syncfusion.Licensing                {19.3.0.57}                              
System.Security.Principal.Windows   {5.0.0}                                  
Syncfusion.EJ2.AspNet.Core          {19.3.0.57}                              
Microsoft.Extensions.Configurati... {6.0.0}                                  
Newtonsoft.Json                     {13.0.1}                                 
Microsoft.jQuery.Unobtrusive.Ajax   {3.2.6}                                  
Microsoft.Extensions.Configurati... {6.0.0}                                  
Microsoft.Extensions.Configurati... {6.0.0}                                  
Microsoft.AspNetCore.Mvc.Newtons... {6.0.0}                                  
Microsoft.Extensions.Configurati... {6.0.0}                                  
Microsoft.AspNet.Mvc                {5.2.7}                                  
Syncfusion.EJ.AspNet.Core           {19.3.0.57}                              
Microsoft.Extensions.PlatformAbs... {1.1.0}                                  
System.Data.SqlClient               {4.8.3}                                  
Microsoft.AspNetCore.Session        {2.2.0}                                  
Microsoft.Extensions.Configuration  {6.0.0}                                  
Syncfusion.Pdf.Net.Core             {19.3.0.57}                              
Microsoft.Extensions.Primitives     {6.0.0}                                  
Twilio                              {5.68.2}                                 
Microsoft.Extensions.Logging        {6.0.0}                                  
morelinq                            {3.3.2}                                  

Also, when I look at the output folder on the server, I absolutely do see System.Diagnostics.EventLog:

enter image description here

Any advice?

Thanks!

Upvotes: 4

Views: 4864

Answers (1)

Mike Luken
Mike Luken

Reputation: 525

I had Microsoft.AspNet.Mvc 5.2.7 still in my package list, which was pulling in an older version of System.Diagnostics.EventLog. Once I removed that, it started working...

Upvotes: 1

Related Questions