System.MissingMethodException: No parameterless constructor defined for this object - Windows Forms App

34 Views Asked by At

I went back to the old project - Windows Forms app in .NET Framework which compiled version works fine. I've been trying to run this project but I got error:

System.MissingMethodException: No parameterless constructor defined for this object.

I'm using Microsoft.Extensions.DependencyInjection. Obviously all needed services are registered and all of them have apropiate constructor (all with parameters) and as I mentioned before - this project had worked without any problem few months ago.

Unfortunately I can't insert the original code but these are normal type classes like:

public class SomethingService : ISomethingService
{
    private readonly IRepository repository;
    private readonly ILogger<ISomethingService> logger;

    public SomethingService(IRepository repository, 
        ILogger<ISomethingService> logger)
    {
        this.repository = repository;
        this.logger = logger;
    }
}

Registered like: services.AddTransient<ISomethingService, SomethingService>();

I've reinstalled all nuggets, been trying to re-define constructors, change the order of certain dependencies execution and move the project to other environments - always the same story.

0

There are 0 best solutions below