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.
158
questions with no upvoted or accepted answers
6
votes
0answers
718 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 ...
5
votes
1answer
252 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
0answers
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
0answers
4k 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 ...
4
votes
0answers
698 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
1answer
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
0answers
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 ...
3
votes
1answer
1k 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
0answers
341 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
0answers
956 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
0answers
641 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
0answers
52 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
0answers
117 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
0answers
398 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
0answers
679 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
0answers
256 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
1answer
201 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
1answer
1k 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
1answer
293 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
0answers
915 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
0answers
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
0answers
538 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
1answer
302 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
1answer
728 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
0answers
610 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
0answers
860 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
1answer
24 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
0answers
37 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
0answers
36 views
Injected constructor is not called for command handlers
I have created a (.NET Core) Web API based application. The application uses MediatR package to handle the commands called from the APIs. In these command handlers I am trying to inject an instance of ...
1
vote
0answers
31 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
1answer
86 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 ...
1
vote
0answers
220 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
0answers
67 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
1answer
334 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
0answers
249 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 ...
1
vote
0answers
116 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
1answer
66 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
0answers
156 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
0answers
131 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
1answer
470 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
0answers
409 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
0answers
400 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
0answers
197 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
1answer
793 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
0answers
116 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
1answer
314 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 ...
1
vote
0answers
336 views
Simple Injector Webforms, property injection into masterpages
I have followed the setup guidelines for webforms integration and I am getting injection into Pages with no problems. But I cannot get property injection to work on a master page. I have modified the ...
1
vote
0answers
163 views
SessionPerWebRequest UoW SimpleInjector ActionFilterAttribute
I am using SimpleInjector and want to create a UnitOfWork Per WebRequest Using an UnitOfWorkFactory.
I want to do this by using an ActionLiterAttribute so that every web request will begin a new ...
1
vote
1answer
928 views
SimpleInjector can't inject string after update
After updating SimpleInjector from version 2.8.3 to v3.0.1, it returns an error when I try to pass the connection string into a constructor. This was working fine in the past but after the update ...
1
vote
0answers
196 views
Simple injector 3.0 - generics registration
I've upgraded to 3.0, and I'm having a little bit of trouble. The following registration worked in 2.8, but is throwing an error in 3.0. I'm thinking I'm not registering it correctly in 3.0, but I'm ...