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.
162
questions with no upvoted or accepted answers
7
votes
0
answers
956
views
AbstractValidator classes are always singletons despite being registered as transient
I'm using SimpleInjector 4 and FluentValidation 7. My AbstractValidators have a dependency on my DbContext.
public class Validator : AbstractValidator<LocationModel>
{
public ...
6
votes
0
answers
8k
views
Why IDependencyResolver removed from ASP.NET Core and what should I use instead?
I'm using simple injector and I couldn't find IDependencyResolver in .net core 2, is it right choice to use IServiceProvider instead of using IDependencyResolver, since there is no "IDependencyScope ...
5
votes
1
answer
395
views
How to clean up instances created by SimpleInjector during verification?
As a part of creating my SimpleInjector container, I've followed recommended practices and called container.Verify() to check that my type registrations make sense.
This works well and has caught a ...
5
votes
0
answers
2k
views
Why is Thread.CurrentPrincipal.Identity.IsAuthenticated false when creating an instance using Simple Injector
Basically I am trying to get the current set of claims for an authenticated user (via bearer token) currently accessing a Web Api; by injecting the current principal into a helper class, which is then ...
4
votes
0
answers
2k
views
Implementing Hangfire with Simple Injector in a net.core WebApi
NOTE:see the edits at the end.
Trying my hand at understanding how to implement Hangfire + Simple Injector in a net core Web Api test project (already used SI in an asp.net project [but setting up ...
4
votes
0
answers
792
views
How to inject async-scoped dependencies into IOAuthAuthorizationServerProvider?
I've implemented IOAuthAuthorizationServerProvider in a WebApi2 project. I am using SimpleInjector and have registered services, repositories, etc. with AsyncScopedLifecycle. I am injecting these ...
4
votes
1
answer
1k
views
Unable to register Api Controller using Simple Injector?
I have a WebApi that uses Simple Injector that was working perfectly fine, but i had to implement OAuth in to the project. Now i have done that and my ApiControllers give me an error like Simple ...
3
votes
1
answer
2k
views
Simple Injector: cannot register Web API controllers with AsyncScopedLifestyle
I am trying to integrate Simple Injector (4.0.12) in my .NET (4.6.1) Web API Project, but cannot find a way to register all Web API Controllers with the correct AsyncScopedLifestyle.
When I try ...
3
votes
0
answers
369
views
How to inject SignalR hub to a regular class using SimpleInjector
In a console app I'm using
OWIN
Signalr
SimpleInjector
I have an Engine class which needs NotificationHub and NotificationHub needs ClientWriter to work. I managed to setup dependencies but it ...
3
votes
0
answers
983
views
How can I use Simple Injector as a boostrapper in NancyFX?
I have seen the following two links
Nancy FX Discussion,
Simple Injector Discussion
However, I really want to use the simple injector.
Is there anyway I can use the simple injector as Bootstrapper in ...
3
votes
0
answers
669
views
Simple Injector - Injecting ISecureDataFormat into AccountController
I am currently working on setting up an MVC 5 project with Web API 2 and Identity 2.0. In the template, the Account Controller constructor has two parameters - ApplicationUserManager and ...
2
votes
0
answers
337
views
How to inject cancellation token in a HostedService timer with Simple Injector
I'm trying to create a console application that run ahosted service with Simple Injector and I looked to the example at generichostintegration.
Now I would like to change IProcessor.DoSomeWork to be ...
2
votes
1
answer
220
views
Service locator implicit request scopes
I've created a small service locator which I will use in ActionFilterAttributes and IHttpModules. At the time of Writing I'm using simple injector, but I want to make it container agnostic. The idea ...
2
votes
0
answers
128
views
Simple Injector Activation Exception Xamarin Forms. I can't navigate through my application
I'm using simple injector for DI on my solution. After xamarin updating it stop working. I can navigate once and then it throws Activation Exception : This instance has already started one or more ...
2
votes
0
answers
340
views
Dependency injection in end-to-end tests
I'm using Selenium along with NUnit for my end to end tests. I have some utility classes, loggers etc that I'm reusing throughout my tests. I would like simple injector to provide those instances to ...
2
votes
0
answers
649
views
Simple Injector support for Xamarin Forms 4.0
We are planning to use Simple Injector with the Xamarin Forms 4.0 and is struggling to find any documentation around this. The issue is when we try to inject the ViewModel to a Page (using constructor ...
2
votes
0
answers
435
views
Property Injection for User Controls in WinForms
I have inherited an a VB.NET WinForms application. It is very poorly written with a lot of bad practices. The first order of business is to get some DI into the app with a container to resolve the ...
2
votes
0
answers
919
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 ...
2
votes
0
answers
281
views
Retrieve the claims using Simple Injector
The project I am working on is storing data inside the claim that I need to retrieve. The project is using Simple Injector as its IoC container and I have implemented the ...
2
votes
1
answer
232
views
Simple Injector - Custom WebViewPage
I've a small application (for now) that uses translations.
My translation Service is called Translator (ITranslator).
My problem is that I don't want to retrieve this class in every controller (which ...
2
votes
1
answer
2k
views
Unable to use Simple Injector for DI
I'm new to using DI and ASP.NET and I'm having a hard time getting Simple Injector to work. I've added SimpleInjector 3.1.5 as a reference using NuGet. Here is what I have so far:
Global.asax.cs:
......
2
votes
1
answer
324
views
SimpleInjector, OWIN and ASP.Net MVC integration
According to the SimpleInjector documentation, we can define a Scope that will live during the OWIN request like this.
public void Configuration(IAppBuilder app) {
app.Use(async (context, next) =&...
2
votes
0
answers
1k
views
AspNet.Identity throws InvalidOperationException when used with SimpleInjector
I have a simple ASP.NET vNext project, with ASP Identity and SimpleInjector configured (according to http://simpleinjector.readthedocs.org/en/latest/aspnetintegration.html).
Registration works fine, ...
2
votes
0
answers
5k
views
What causes 'access security critical type System.Web.Http.HttpConfiguration failed'?
So, I have an ASP.NET MVC/WebAPI 2 project targeting .NET framework 4.5.2 and I am trying to use SimpleInjector (DI) with the same container for the MVC controllers and the WebAPI controllers and I ...
2
votes
0
answers
545
views
Automapper and SimpleInjector using WebApiRequestLifestyle
I'm inserting Automapper (latest version from Nuget) into my project (WebApi2, framework 4.5.1) and using SimpleInjector (latest version from Nuget).
My problem is that before using Automapper ...
2
votes
1
answer
334
views
Is there a way to explicitly register open generic decorators with castle windsor
I use castle windsor a lot in a project i'm working on and use decorators a little so I might have something like this in my installer
Component.For<IMyViewModelService>().ImplementedBy<...
2
votes
1
answer
823
views
Using SimpleInjector with NServiceBus to inject IBus Bus property
I am trying to get acquanited with NServiceBus 5 using its own dependency injection container, and with SimpleInjector, which is our container of choice.
There is a way to tell NServiceBus to inject ...
2
votes
0
answers
637
views
SimpleInjector – Make sure that the controller has a parameterless public constructor
I use nuget simple injector mvc integration quick start to install simple injector v2.5.2 and related packages to my helloworld mvc project. It works fine in my local express IIS. But after I upload ...
2
votes
0
answers
865
views
MVC 5 and Simple Injector on VS 2012 EntryPointNotFoundException
I have application in .NET Framework 4.5 and SimpleInjector. When my app was without SI its start without problems, but when I added SI I cannot run it.
This is my code in Global.asax:
public static ...
1
vote
1
answer
476
views
You are trying to resolve a cross-wired service, but are doing so outside the context of an active (Async Scoped) scope with Simple Injector
I'm building a .NET Core console app that uses Simple Injector and SimpleRabbit to pubish messages to RabbitMQ.
I've run into a run time exception when I attempt to get an registered instance from a ...
1
vote
0
answers
158
views
How do I use a SimpleInjector container with HostBuilder?
I'm building .NetCore console app which uses SimpleRabbit (RabbitMQ).
I am attempting to use HostBuilder() to this purpose (dependecy injection, configuration, services).
I create a SimpleInjector ...
1
vote
1
answer
67
views
How can I get/create an instance of an object on Simple Injector container depending on the asp.net web api 2 session?
I have an asp.net web api 2 project in which I register a singleton LoginData
containerLocal.RegisterSingleton<ILoginData>(
() => new LoginData { LanguageCode = null, UserCode = null });
...
1
vote
0
answers
394
views
Rebus.Async with SimpleInjector Request/Reply MessageCouldNotBeDispatchedToAnyHandlersException
I'm using Rebus.Async to reply a processing data to WebApi request using command CQRS.
1. I registered bus with the following configuration:
public static IContainerRegistry RegisterRebusInMemory(
...
1
vote
0
answers
63
views
Simple Injector: freeing up event subscription on injected instance
In our WPF project, we use Simple Injector to inject stores (implementing a common interface called IFluxStore<T>) into ViewModels. The stores are registered as singletons, because they have an ...
1
vote
0
answers
552
views
How to use Simple Injector with Xamarin Forms and Entity Framework Core?
I'm trying to setup dependency injection in my Xamarin Forms application. I have got constructor injection all working with Simple Injector. However, when I start to use Entity Framework I am ...
1
vote
0
answers
205
views
Dispose Simple Injector async scope in hangfire jobfilter lifecycle
I'm using Hangfire along with simple injector. I would like to do some logging if a job failed or succeeded. As far as I know, OnStateElection is the place to handle this.
However, since ...
1
vote
1
answer
759
views
Create an instance of IHubContext<MyClass> in a webjob with Simple Injector
I'm using .NET Core 2.2 and SignalR Core and I need to inject IHubContext<MyClass> via Simple Injector in my Webjob.
It works perfectly in my web app but when I'm trying to reach my service via ...
1
vote
0
answers
221
views
Injecting a SignalR hub using Simple Injector
I've seen a few examples where a custom hub activator is registered, e.g. GlobalHost.DependencyResolver.Register(typeof(IHubActivator), () => new SimpleInjectorHubActivator(container));. If I ...
1
vote
0
answers
207
views
Simple Injector - Transient object implementing IDisposable, depending on other transient objects
I am writing a service that tells multiple classes implementing the interface IDeviceFinder to go look for connected devices, which the service will put in a cache for other objects to use.
The ...
1
vote
1
answer
95
views
How to use Simple Injector with svc-less service implementations
I'm considering switching from Autofac to Simple Injector due to seemingly better decorator support. But I'm very fond of the way you register and host svc-less WCF services with Autofac and I can't ...
1
vote
0
answers
246
views
SimpleInjector injects an empty collection when using a generic interface
I'm trying to implement a similar scenario of CompositeValidator in the Simple Injector docs.
Here is the composite class:
public class CompositePriceCalculator<T> : IPriceCalculator<T>
...
1
vote
0
answers
169
views
JWT & Simple Injector. Set connectionstring OnTokenValidated
I am new to this kind of concepts so i am kinda stuck on this (explanation of what i aim for a little bellow).
I have the following code in a rest web api:
UnitOfWorkProvider.cs
public class ...
1
vote
1
answer
626
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" ...
1
vote
0
answers
494
views
Using Simple Injector with EF in WPF app
In my wpf app I need to be able to read/write data from specific table/tables, so, as I'm using SimpleInjector to use all services and stuff.
So, basically I want to be able to use repository in some ...
1
vote
0
answers
450
views
Simple Injector and Strategy pattern (Register dependency runtime based on request)
I am working on Simple injector DI library. I need good ideas on how to register interface which is consumed in more than one provider (component).
Below is my requirement.
It is Web API project ...
1
vote
0
answers
461
views
How to create a Generic Dependency Injection Container creator using SimpleInjector
I have a method inside a library like below which is based on SimpleInjector 3.3.0:
public static Container GenerateContainer(ScopedLifestyle lifestyle, IServiceCollection services)
{
...
1
vote
0
answers
236
views
Using Simple Injector to register lazy parameters by reflection
My Service classes have two IRepository instance(ICacheRepository and ISqlRepository), ICacheRepository implementations always use in services, but ISqlRepository implementations sometimes use.
I ...
1
vote
1
answer
933
views
Replace Splat in ReactiveUI with Simple Injector
I'm trying to replace Splat in ReactiveUI with Simple Injector. I am using the package addon for SI. Here's my configuration:
public void RegisterServices(Container container)
{
// I ...
1
vote
0
answers
121
views
c# WCF [Simple Injectior] injection pattern
I have seen lots of examples on how to do this, but as I am a newbie to DI, I thought it best to ask a question specifically for my issues. Again, I apologize if this has been asked already.
We have ...
1
vote
1
answer
391
views
SimpleInjector named parameter registration
I have a service constructor with multiple same-type parameters dependencies
class Service{
public void Service (String connectionStringOne, string connectionStringTwo)
{}
}
How can I do ...