I have the following structure for my project:
firstProj
|
+--- src
| |
| +--- Repositories
| |
| +--- MyFirstRepository.cs
| +--- IMyFirstRepository.cs
|
secondProj
|
+--- src
|
+--- Repositories
|
+--- MySecondRepository.cs
+--- IMySecondRepository.cs
The firstProject contains a Startup.cs file, that has the following:
services.Scan(scan => scan
.FromEntryAssembly()
.AddClasses(classes => classes
.InNamespaces("my.namespaces"))
.UsingRegistrationStrategy(RegistrationStrategy.Replace(ReplacementBehavior.ImplementationType))
.AsImplementedInterfaces()
.WithScopedLifetime());
The first repository is recognized and added to the pool, however, the second one doesn't. Both repositories are under my.namespace namespace, and if I manually add the first file:
services.AddScoped<IMyFirstRepository, MyFirstRepository>()
it works. Any ideas on how to make Scrutor scan all files?
try this