question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'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