'IServiceCollection' does not contain a definition for 'Scan'

See original GitHub issue

In a .NET Core App I’m facing this error:

Error	CS1061	'IServiceCollection' does not contain a definition for 'Scan' and no extension method 'Scan' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)

The code of ConfigureServices looks like this:

services.Scan(scan => scan
    .FromAssemblies(typeof(MaterialCommandHandler).GetTypeInfo().Assembly)
    .AddClasses(classes => classes.Where(x => {
        var allInterfaces = x.GetInterfaces();
        return
            allInterfaces.Any(y => y.GetTypeInfo().IsGenericType && y.GetTypeInfo().GetGenericTypeDefinition() == typeof(IHandler<>)) ||
            allInterfaces.Any(y => y.GetTypeInfo().IsGenericType && y.GetTypeInfo().GetGenericTypeDefinition() == typeof(ICancellableHandler<>));
    }))
    .AsSelf()
    .WithTransientLifetime()
);

I’m using Scrutor 2.0.0.

image

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
khellangcommented, Jul 24, 2017

Glad you figured it out! BTW, FromAssemblies can be replaced with FromAssemblyOf<MaterialCommandHandler> and the Where clause could be replaced with AssignableToAny(typeof(IHandler<>), typeof(ICancellableHandler<>)). I just typed this on my phone, so I can’t guarantee that it compiles, but you get the gist 😉

0reactions
thepirat000commented, Apr 26, 2022

You mean scrutor

Read more comments on GitHub >

github_iconTop Results From Across the Web

.net - 'IServiceCollection' does not contain a definition for ' ...
I'm using .NET 6 in Program.cs: builder.Services.AddMediatR(Assembly.GetExecutingAssembly());. I get: 'IServiceCollection ...
Read more >
'IServiceCollection' does not contain a definition for 'Scan'
In a .NET Core App I'm facing this error: Error CS1061 'IServiceCollection' does not contain a definition for 'Scan' and no extension method ......
Read more >
Fix: IServiceCollection does not contain a definition ... - YouTube
Fix: IServiceCollection does not contain a definition for 'AddDefaultIdentity' and no accessible extension method 'AddDefaultIdentity' ...
Read more >
IServiceCollection Interface
Specifies the contract for a collection of service descriptors.
Read more >
IServiceCollection doesn't contain a definition of ...
Issue resolution for error IServiceCollection doesn't contain a definition of AddSwaggerGen in ASP.NET API after adding the Swashbuckle NuGet package.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found