autofac / Autofac

An addictive .NET IoC container
https://autofac.org
MIT License
4.44k stars 836 forks source link

"The parameters to the Event method do not match the parameters to the WriteEvent method." message spam the console when Resolving #1381

Closed valhentai closed 1 year ago

valhentai commented 1 year ago

Describe the Bug

I am developping a C# \ WPF Application. Since a few month, when running the application in debug mode, the console is spammed by the messageThe parameters to the Event method do not match the parameters to the WriteEvent method. This may cause the event to be displayed incorrectly. This message can appear several dozen of time per seconds which considerably slow down the application. Fortunatly, it doesn't happen in realease so our clients are not impacted but it make debbuging very hard.

The problem seems to come from AutoFac. The message appear every time AutoFac.IContainer.Resolve() is called.

I tried to update Autofac from 6.5.0 to 7.0.1 but it does not change anything. Our application target NETFramework 4.7.2

It seem it come from a windows update in the past months because it appeared on our differents computer one after an other without us changing any dependencies.

How to reproduce

Here a simplified version of the code we are using to register our services. Tell me if you need a more complete version.

Module declaration

public class ServiceInjectionModule : Module
    {

        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);

            ...
            builder.Register<ISomethingService>(_ => new SomethingService()).SingleInstance();

            ...

Container construction

            var builder = new ContainerBuilder();

           // module registration
           ....
            // _container is IContainer
            _container = builder.Build();

Service resolving
This is where we got the message in the console

            var service = _container.Resolve<ISomethingService>();

Do you have any idea how to solve this problem ? Is it a bad utilisation on our side which has been made visible with a windows update ?

Dependency Versions

Autofac: 6.5.0 ( problem still here when updating to 7.0.1 ) NETFramework 4.7.2 Windows 10 and 11

tillig commented 1 year ago

As noted in the issue template, usage questions like this should go on Stack Overflow, where we do actively monitor. Do not double post here, it eats up time trying to answer the same question twice.

You did post it there and I already commented that there's not enough info to answer the question. Go read their description on how to ask a good question, especial the part about creating a minimal reproducible example. There's not enough code to reproduce what you're seeing, there's no exception stack trace to explain where exactly the error is happening, and this isn't an exception message generated by Autofac. There is no possible way to guess what is happening, so we can't answer.