Questions tagged [simple-injector]

Simple Injector is an Dependency Injection library for Microsoft .NET, .NET Core, .NET Standard, Windows Phone, Windows Store Apps, and Mono.

simple-injector
Filter by
Sorted by
Tagged with
2 votes
1 answer
119 views

Catalog concept instead of complex constructors?

In my current project my manager is forcing some design concept for dependency injection I would like to discuss because I’m curious what a specialists of dependency injection think about this ...
dnf's user avatar
  • 1,719
0 votes
1 answer
881 views

How to inject list of base interfaces to class

I have a program where I have some services with custom interfaces but all of them inherit from IService. The services are registered with their custom interfaces as singletons in Simple Injector ...
dnf's user avatar
  • 1,719
0 votes
1 answer
47 views

Verify forces lazy initialization of services

Firstly, thank you- I have become a better programmer by being "forced to" by Simple Injector. Very early in the bootstrap of my program I setup my root container and shortly afterward call container....
user1221237's user avatar
0 votes
0 answers
182 views

using simple injector with aspnet.identity

I'm trying to use simple injector with my mvc project, and I'm unclear how to complete all registrations for framework code. In particular, with this aspnet.identity code.In general, since this isn't ...
arod's user avatar
  • 124
1 vote
1 answer
2k views

Creating custom Simple Injector Scope in Web Forms

I have a text box and a button in my Windows forms application. When the start key is pressed with the value written in the textbox, a new Form should be opened with this value. I want to create a ...
Baran's user avatar
  • 1,398
0 votes
1 answer
510 views

Is it okay to use a static Simple Injector DI container in my Azure Function?

I have a Simple Injector DI Container which helps instantiate the various dependencies I'll need for my function. I know static variables have special treatment in Azure Functions and I want to make ...
Slothario's user avatar
  • 2,950
0 votes
1 answer
237 views

Controller disposal in IHttpControllerActivator

I have a custom IHttpControllerActivator for my web api controllers which I'm using along with simple injector: public sealed class ApiControllerActivator : IHttpControllerActivator { private ...
Johan's user avatar
  • 35.3k
0 votes
1 answer
520 views

simple injector how to inject batch registered generic type into constructor

Simple Injector newbie. I've reviewed this documentation https://simpleinjector.readthedocs.io/en/latest/advanced.html to learn about how to work with generic types with simple injector. I can't ...
arod's user avatar
  • 124
0 votes
1 answer
180 views

IOC Container locking during integration tests

When doing a check in, I run integration tests, but every once in a while it seems that my container is locking up. It happens on different integration tests It doesn't always happen The error is : ...
RandomUs1r's user avatar
  • 4,070
0 votes
0 answers
232 views

How to configure Identity Framework's AuthenticationManager with SimpleInjector?

Im using SimpleInjector in my MVC application. The application is using Identity for Authentication. Im getting an error when I navigate to controllers that use AuthenticationManager in the controller....
scouty's user avatar
  • 155
0 votes
1 answer
196 views

Simple Injector Transaction Handling

I am migrating my project from Spring.Net to Simple Injector. In Spring.Net, there is a concept of having several functions nested under a single transaction using transaction decorator. The ...
Algi's user avatar
  • 195
3 votes
1 answer
975 views

Simple injector Web API integration package for .NET core?

When integrating simple injector in to a pure .net core web api project, should I still use the "ASP.NET Core MVC Integration NuGet package"? I was expecting to find a separate integration package ...
filur's user avatar
  • 1,844
0 votes
1 answer
46 views

How can I map a generic abstraction to a generic implementation in Simple Injector?

I could not come of with a better title so please feel free to change it after you have read the entire question. I have the following classes: public class Foo<T> : IFoo<T> {} public ...
MaYaN's user avatar
  • 6,864
0 votes
1 answer
762 views

Simple Injector using WCF

I am new to Simple Injector. I have a WCF service with a class Testservice implementing a interface ITestService. As per the Simple Injector documentation, in the svc markup I have added the factory ...
Algi's user avatar
  • 195
0 votes
1 answer
69 views

Simple Injector: injecting navigation properties into repositories

Let's assume we have an entity with multiple many to many navigation fields of the same type: class Post : IdProvider<TPrimaryKey> where TKey : struct { ... public virtual ...
SimpleV's user avatar
  • 396
0 votes
1 answer
321 views

Custom IHttpControllerActivator for MvcControllers

Is there any way to register a custom IHttpControllerActivator for my Mvc controllers registered in simple injector, in a similar fashion to what can be done with Web API? As soon as I run ...
Johan's user avatar
  • 35.3k
0 votes
0 answers
186 views

MassTransit IoC implementation with SimpleInjector

I have to use MassTransit on my WebApi project, but I can't find any sample of how to implement it with Simple Injector on a WebApi 2 (OWIN) application. Any help will be appreciated.
CesarD's user avatar
  • 573
2 votes
1 answer
893 views

Simple Injector Usage with UseApplicationInsights/AddApplicationInsights in ASP.NET Core

I am building an ASP.NET Core 2.1 app. For app insight telemetry I have my custom class but I also want to use built-in ITelemetryInitializer's. Does Simple Injector automatically resolves these ...
user7784348's user avatar
1 vote
1 answer
315 views

Simple Injector doesn't contain ASP.NET Core services when using Auto Cross-Wiring

I am using Simple Injector with ASP.NET Core 2.1 I have enabled auto cross wiring as shown below but when I do container.GetCurrentRegistrations() I don't see any ASP.NET Core Services available in ...
user7784348's user avatar
1 vote
1 answer
441 views

Why does this Simple Injector registration result in an empty collection?

I have a generic interface which has many implementations, possibly in different assemblies. I have Simple Injector 4.3.0 installed in my project via NuGet, and want to register the implementors as a ...
Conduit's user avatar
  • 2,705
0 votes
0 answers
85 views

Simple Injector Generic Registrations are not Resolved

I am using Simple Injector IOC. I have below registration which not getting resolved, I am getting the error as shown below. container.Register( typeof(IQueryHandler<,>), typeof(...
user7784348's user avatar
0 votes
1 answer
482 views

AspNet Core AppInsights Integration

I am integrating app insights into our AspNet Core app(Target Framework .Net 4.7.1). I have two queries regarding app insights integration. I am using SimpleInjector IOC, so does it make sense to ...
user7784348's user avatar
5 votes
1 answer
284 views

Set Simple Injector's Logger

I've set my application to use Simple Injector as DI container, I've registered all the repositories/services and I was looking to set up the latest step: Logging what Simple Injector writes as output ...
advapi's user avatar
  • 3,751
1 vote
1 answer
875 views

How to change registered (Simple Injector) DbContext's connection string after user's authorization?

I'm building ASP.NET Core Web Api with Simple Injector and have the following problem: The data for each user is stored in his individual base (but with the same schema), which is known only after he ...
Michael Black's user avatar
1 vote
1 answer
421 views

How to use Ninject's Named bindings in Simple Injector?

I have an MVC application using Ninject for DI and I'm planning to migrate the same to Simple Injector. But I couldn't find any alternatives for replacing the named binding of Ninject with Simple ...
Jibin Balachandran's user avatar
2 votes
2 answers
160 views

SimpleInjector: End-to-end testing of controller's methods on a test database

I have a web app with several REST API controllers. This controllers got injected repositories as per this tutorial using SimpleInjector. I'd like to add some end-to-end testing to my project to make ...
SimpleV's user avatar
  • 396
0 votes
1 answer
690 views

Injecting a configuration class into a constructor using Simple Injector

I have a class with configuration settings. So, I want to use Simple Injector for using my config class like this: public class Host { private readonly ServiceConfig _config; public Host(...
Mikhail Kostiuchenko's user avatar
1 vote
2 answers
329 views

Building a plugin-based application with Simple Injector

I have been given the task to write a technical specification (and later implement) a system that will be build on a few sub-modules. The sub-modules will be developed partly in parallel so I would ...
Casper's user avatar
  • 1,126
0 votes
0 answers
65 views

c# - RegisterConditional Ninject Equivalent

I use Simple Injector in me project. So I Have next code: container.RegisterConditional( typeof(ISearchService<>), typeof(SearchService<>), c => !c.Handled); But I want ...
Mikhail Kostiuchenko's user avatar
1 vote
1 answer
722 views

Simple Injector with ASP.NET Core With Full .NET Framework (.NET 4.7)

I am using ASP.NET Core with the full .NET framework and want to try Simple Injector. In the Nuget manager, I see so many options for Simple Injetcor e.g. "SimpleInjector.Integration.AspNetCore.MVC" ...
user7784348's user avatar
0 votes
0 answers
446 views

Simple Injector configuration with a DbContext in a console application

EDIT: I will give it another try. Below is all of the pertinent code: //in BaseProject for other console apps (a class library): public class SimpleInjectorInitializer { public ...
RobC's user avatar
  • 1,355
12 votes
2 answers
5k views

Wiring up Simple Injector in WebForms in .NET 4.7.2

With the changes in .NET 4.7.2, constructor injection is now possible in Web Forms. I have gotten Simple Injector working with Web Forms, but would like some input as to if there any "gotchas" I might ...
Bradford Dillon's user avatar
0 votes
1 answer
235 views

Custom controller activator for MVC controllers

I would like to know if there is a way to implement a similar solution to Register subset of Web API controllers with simple injector, but for MVC controllers rather than web api controllers? More ...
Johan's user avatar
  • 35.3k
2 votes
0 answers
1k views

Audit.EntityFramework with Simple Injector On .Net Core

I'm currently using .net core 2.0 along with Audit.EntityFramework to audit changes on my entities. I've gone the route of creating my own CustomProvider as explained here DataProviders brief excerpt ...
Darren's user avatar
  • 355
1 vote
1 answer
262 views

Inject two specific interface implementations into constructor with Simple Injector

I have and interface IConnector. And have some implementations, say SomeConnector. And my use case looks like: public class Worker : IWorker { public Worker(IConnector dataConnector, IConnector ...
shda's user avatar
  • 733
13 votes
2 answers
7k views

Injecting Simple Injector components into IHostedService with ASP.NET Core 2.0

In ASP.NET Core 2.0, there is a way to add background tasks by implementing the IHostedService interface (see https://learn.microsoft.com/en-us/aspnet/core/fundamentals/hosted-services?view=aspnetcore-...
chrisbuttacavoli's user avatar
1 vote
1 answer
3k views

The container can't be changed after the first call to GetInstance, GetAllInstances, Verify, and some calls of GetRegistration

I cant figure out why I am getting this error below within the RegisterCollection method. Am I doing the setup incorrectly? The container can't be changed after the first call to GetInstance, ...
Mike Flynn's user avatar
  • 23.5k
0 votes
1 answer
603 views

The constructor of type PaymentManager contains the parameter with name 'paymentMethods' and type List<IPaymentMethod> that is not registered

I am also getting the error below. Is this because its not a List, and if so how do I correct this? container.RegisterCollection<IPaymentMethod>(new[] { typeof(AuthorizeNetProvider), ...
Mike Flynn's user avatar
  • 23.5k
0 votes
1 answer
169 views

Ninject WithConstructorArgument to Simple Injector Implementation

What is the direct implementation from Ninject's WithConstructorArgument to a Simple Injector implementation? var emailTemplates = new EmailTemplates { MasterPageTemplate = MVC.Email.Views....
Mike Flynn's user avatar
  • 23.5k
0 votes
1 answer
78 views

Convert Ninject ToConstant to Simple Injector Implementation

What is the equivalent code in Simpleinjection from this Ninject code using ToConstant. Func<Type, IValidator> validatorFactory = type => { var valType = typeof(Validator<>)....
Mike Flynn's user avatar
  • 23.5k
4 votes
2 answers
2k views

Simple Injector Inject into PageModel ASP.NET Core Razor Pages

Simple Injector (SI) Documentation here shows how to integrate SI with ASP.NET Core: private void IntegrateSimpleInjector(IServiceCollection services) { container.Options.DefaultScopedLifestyle = ...
Rodrigo Riskalla Leal's user avatar
2 votes
1 answer
1k views

Controller is registered as transient, but implements IDisposable

var container = new Container(); container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle(); container.RegisterInstance<IDbConnection>(new SqlConnection(connectionString)); ...
user avatar
1 vote
1 answer
2k views

The configuration is invalid. The type Service is directly or indirectly depending on itself

Error: The configuration is invalid. Creating the instance for type IUserService failed. The configuration is invalid. The type PatientService is directly or indirectly depending on itself. The ...
Irfan Y's user avatar
  • 1,300
4 votes
1 answer
762 views

IoC in WCF hosted in Windows Service and container lifetime per call

I have a few clients (web and desktop apps) that must connect to a few services which are WCF services hosted in a Windows Service. These services must get data from one or more databases, but it is ...
CyclingFreak's user avatar
  • 1,625
3 votes
1 answer
265 views

Simple Injector - RegisterCollection and RegisterDecorator using Composite pattern and interface inheritance

How can I register types as IPollingService<TContext> so that they'll be decorated via container.RegisterDecorator(typeof(IPollingService<>), typeof(ContextAwarePollingServiceDecorator<&...
Jeff's user avatar
  • 2,211
0 votes
1 answer
139 views

ELMAH stylesheet not working with Simple Injector

In an ASP.NET app, when trying to work with both Simple Injector and ELMAH, the following get request returns a 500 error: GET /elmah.axd/stylesheet returns a 500 error. The error message: No ...
desm's user avatar
  • 311
3 votes
1 answer
815 views

Simple Injector Inject IEnumerable<Func<T>>

How Can I inject IEnumerable<Func<T>> using Simple Injector? Just to add some context, I'm trying to create all EventHandlers that knows how to handle one specific Event. So here is my ...
Rodrigo Riskalla Leal's user avatar
1 vote
1 answer
96 views

Nested Decoratee with a Factory in between

We've got a hierarchy of 3 decoratees implementing an interface like: public interface IRetrieve { List<Widget> Retrieve(List<long> ids); } We are attempting to use the following ...
Marty's user avatar
  • 1,182
0 votes
1 answer
93 views

How to Build a UnitOfWork Scoped Object Graph within Simple Injector

Our web sites are currently using Ninject; however, we are looking at moving to SimpleInjector (since our tests show a 26% speed increase). However, we can't get the DbContext's scoping to work ...
Kabua's user avatar
  • 999
1 vote
1 answer
93 views

Simple Injector 4.1: Overriding Parameter Injection Behavior

I'm new to using DI in C# and had a look at Windsor, Ninject, Autofac, Unity and Simple Injector. I originally discarded Simple Injector because I needed value-type injection (fx. connection strings) ...
Casper's user avatar
  • 1,126

1
4 5
6
7 8
23