3,899 questions
0
votes
0
answers
23
views
How to use unity container with log4net (Specific with .net 4.7.2) [duplicate]
I have used below code to this dependency injection with unity framework along with log4net.
Working code snippet:
var container = new UnityContainer().RegisterType<ILog>(new InjectionFactory(x =...
0
votes
1
answer
83
views
Unity Extenject how to properly organize access from SceneContext to ProjectContext
I have a question about architecture with Extenject (Zenject).
I have a GameStateMachine that is located in the ProjectContext and manages the game states. One of these states (LoadGameState) needs ...
0
votes
0
answers
30
views
Does Unity Interceptor alter the behaviour of Prism's BindableBase.SetProperty method?
I am using Unity container with Prism's BindableBase class, and I suspect that Unity's VirtualMethodInterceptor is altering the behaviour of the SetProperty method in BindableBase. This seems to be ...
0
votes
1
answer
267
views
Unable to resolve service for type 'Swashbuckle.AspNetCore.Swagger.ISwaggerProvider' only while Using Unity Dependency Injection
I am working on an ASP.NET Core application and integrating Swagger with
Swashbuckle.AspNetCore. My project uses Unity as the dependency injection (DI) container instead of the default ASP.NET Core DI....
0
votes
0
answers
50
views
Use Prism.Unity as DI for ASP.NET Core
I am working on a shared code base between a client and an ASP.NET Core application.
My problem is that ASP.NET Core uses Microsoft.DI and the client uses Prism.Unity, which leads to a log of code ...
1
vote
0
answers
74
views
Problem with solution using Unity container DI provider as well as Built-in one (SignalR issue)
I am working on a old solution web app where all project where created via NET framework. currently we are upgrading all project to NET core, and right now we are moving ASPNET Web App to APSNET Core ...
1
vote
0
answers
928
views
Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server
Title: Microsoft.CodeAnalysis.LanguageServer client Error in VS Code: Incorrect dotnet path
Body:
I'm encountering an issue when trying to run or debug a C# application in Visual Studio Code. The ...
0
votes
1
answer
34
views
RegisterManySingleton as named instances
I want to inject all registered implementaions of a base interface as a collection, but I also want to resolve them as more concrete interface implementations.
For the collection resolving to work, I ...
0
votes
0
answers
35
views
Why are registrations disappearing from UnityContainer?
The Facts
I have 2 UnityContainers – one (let's call it nested) is registered inside the other (let's call it parent) using RegisterInstance() with a name so it can be resolved by it.
// Registration
...
0
votes
1
answer
42
views
Updating Nuget related Unity to latest cause error on WebAPIConfig Registration
There is an .Net solution that contains .Net 4.7.1 MVC Web App and .Net Core 8.0 Library and Web API.
Updated Unity and its related NuGet PAckage as given below.
Unity.5.8.5 -> Unity.5.11.10 and ...
0
votes
1
answer
396
views
Npgsql connection string with Azure Managed Identity expires
I am using Npgsql and EF Core (3.1) in a Net Framework 4.8 application. Due to company infrastructure/policy, I cannot upgrade any higher. I am connecting to the database using an Azure Managed ...
0
votes
0
answers
47
views
Replace dbContext.SaveChanges() by something else?
In my company, we are using Telerik OpenAccess. An extra event is added, every time a dbContext.SaveChanges() is called.
A beginning programmer has used this dbContext.SaveChanges() no less than 93 (!!...
2
votes
1
answer
260
views
Unity - resolve IDistributedCache
I am trying to implement a Redis Distributed cache into a Net Framework 4.8 application. I am in the unfortunate position of having to downgrade a solution that was working perfectly fine in Net Core ...
0
votes
1
answer
593
views
Inject instance from configuration file in net Framework
I am looking at a piece of code in a .NET Core application, and I am wondering if there is an equivalent and elegant way to achieve the result in .NET Framework 4.8
In core, you can "inject" ...
1
vote
1
answer
134
views
Mocking child classes that are initialized in the constructor
I am trying to increase the unit test coverage of an application and ran into an issue with mocking the child class of a base class that is injected into the class I'm trying to test. I am trying to ...
1
vote
2
answers
442
views
Unity IOC Container. How to resolve instance from IOC container outside of the scope where container was created?
I am new to IOC containers and i am trying to understand how to use them. I understand the concept but I having issues on how to practically apply it. Currently, I am using Unity ioc container to ...
0
votes
1
answer
43
views
UnityDependencyResolver can't resolve Enum
I work with .Net Framework 4.7 and UnityDependencyResolver. My customer write a constructor with an Enum as the parameter and UnityDependencyResolver cannot initialize this constructor.
I guess the ...
1
vote
0
answers
76
views
.Net resolving dependency at runtime for return type of method in generic interface
I'm trying to find the best approach for a logic that is supposed to retrieve data from different sources and combine them into a JSON object.
I was able to make it work by serializing the results of ...
0
votes
1
answer
57
views
Resolving Microsoft Logger with Unity throws error
I am using .NET 4.8. and I registered Microsoft.Logger with unity injection:
var factory = new LoggerFactory();
factory.AddLog4Net("log4net.config");
container.RegisterInstance<...
2
votes
1
answer
414
views
Unable to register Microsoft Logger with Unity
I have a Worker with logger and the project is throwing an error:
Resolution of the dependency failed, type = "Test.IWorker", name = "(none)"
public class SimpleWorker : IWorker
{
...
0
votes
0
answers
458
views
How to use MediatR with Unity in legacy ASP.NET 4.7.2?
I am working on a legacy ASP.NET application with target framework .NET 4.7.2. There is already a Unity container implemented (using Microsoft.AspNet.WebFormsDependencyInjection.Unity v1.0.0). Now, I ...
0
votes
1
answer
66
views
No member matching data has been found - Registering Dictionary in Unity Container
I'm attempting to be able to use multiple db connections in different repositories and am following this answer.
I am on .NET Framework 4.8 so things are a little different but everything has been ...
0
votes
2
answers
657
views
Prism Unity Register NLog as Microsoft.Extension.Logging.ILogger<T>
I have a shared Code between my backend and my frontend(WPF), where be backend currently uses NReco.Logging.File which is compatible with Microsoft.Extensions.Logging.ILogger.
But in the fronend, I ...
-4
votes
1
answer
214
views
Error appears while running the program in unity
I installed the Unity Hub. But one error message appears while running the program.
How can I solve this problem ?
I cannot hold on my works because of this problem.
3
votes
1
answer
648
views
UseUnityServiceProvider doesn't works properly on WebApplicationBuilder
I'm trying to migrate from .NET3.1 to .NET6.0 WebAPI. I read this as manual to do this migration.
I'm using UnityContainer as DependencyInjection framework. So in .NET3.1 I have something like this:
...
0
votes
1
answer
123
views
How can the ASP.NET built-in DI read dependencies from a file at runtime?
As you can see in C# Unity container, we can configure a container (a list of dependency and object creation policy) from a file, and it is very good when, I want change a dependency (backend for ...
0
votes
0
answers
361
views
Microsoft extension logging with ASP.NET MVC & VB.NET and Unity dependency injection
I'm trying to use Microsoft extension logging in ASP.NET MVC 5 with dependency injection using Unity but its not showing any logs in the console. Here are my complete code,
Global.asax.vb:
Sub ...
0
votes
0
answers
108
views
What is the AutoFac equivalent of the Unity liftetime HierarchicalLifetimeManager?
I am attempting to convert the below unity container registration into an AutoFac container
container.RegisterType<C1Context>(new HierarchicalLifetimeManager());
container.RegisterFactory<...
1
vote
1
answer
691
views
Unity Container - How to correctly resolve a parameterised MemoryCache that's registered as a singleton
Despite Unity container being deprecated, unfortunately I find myself having to use it since the current wpf codebase I'm working on has been dependent on it for years.
On the server side, I'm able to ...
0
votes
1
answer
69
views
How to default the Unity Lifetime Manager
I'm updating a legacy codebase which was using Unity 3.5 for dependency injection. It's using a custom extension to set the default LifetimeManager, in much the same way as this stackflow question.
...
0
votes
1
answer
261
views
About Reverse Animation in Unity
I'm currently making a game that replays the player in reverse.
Is there a way to make the player animation play in reverse smoothly?
For now, animation is recorded every 0.02 seconds, and when ...
0
votes
1
answer
99
views
Refactor C# Class with Generics from IUnityContainer to Ninject
I would like to move away from the Unity NuGet package for Dependency Injection and switch to Ninject since Unity is no longer being maintained. I was wondering if someone might be able to help me ...
0
votes
0
answers
94
views
Is it possible to have Unity search any child containers if a resolution fails?
I have a unity container with a number of registrations. I then create a child container and add some more registrations. The child container is meant to contain a specific group of registrations ...
2
votes
1
answer
302
views
Injection Constructor Dependency Injection with parameters
I am trying to understand how do I resolve multiple parameters being passed to a constructor from a DI container.
I have an interface IDataAccess (#1) and a class called SQL implementing IDataAccess (#...
1
vote
2
answers
351
views
Unity to DryIoC conversion ParameterOverride
We are transitioning from Xamarin.Forms to .Net MAUI but our project uses Prism.Unity.Forms. We have a lot of code that basically uses the IContainer.Resolve() passing in a collection of ...
1
vote
1
answer
230
views
MediatR PipelineBehavior is not triggered. Prism.Unity is used as the DI-Container
I want to improve my WPF Prism App by using a MediatR Pipelining. But my Pipline "LoggingBehavior" ist not triggert.
The setup of the pipelin in the DI Contianer settings:
...
0
votes
2
answers
404
views
Package manager error every time I create a project
Package manager error every time I create a new project in Unity
occurs. I'm removing the error from the package manager, but it's inconvenient to get the error every time I create a project. How can ...
2
votes
0
answers
77
views
SignalR issue where presumably several hubs are being created and messages are getting lost
I'm using unity as IoC container, and I'm using SignalR. This is how I configure SignalR, in Startup.cs, inside the Configure method
app.Map("/signalr", map =>
{
...
0
votes
0
answers
349
views
.Net Framework 4.7 - HttpClientFactory to use data from the current request context
Web API C# .NET Framework 4.7.2
Unfortunately it is not possible to use NET CORE.
I have to do something a lot like:
Configure HttpClientFactory to use data from the current request context
my ...
0
votes
2
answers
443
views
.NET core SDK cannot be located vscode unity c#
my problem
I am on windows 10 I tried reinstalling .net multiple times and re installed VS Code I am really desperate for solutions now
1
vote
1
answer
278
views
How to use unity container registered Named Type in ServiceStack Requesthandler
I am using ServiceStack (5.12.0) in my ASP.NET service along with Unity Container.
I am registering instances of same type as follows
public static IUnityContainer Create()
{
container....
4
votes
1
answer
3k
views
How to register existing instances in Microsoft.Extensions.DependencyInjection?
I am migrating my .NET applications Dependency Injection framework from Unity Container to Microsoft.Extensions.DependencyInjection.
Now I did not find a way to register an already existing instance ...
1
vote
0
answers
266
views
How to use InjectionFactory in C# Unity
I am new developer using C# and I am working on a project which uses C# Unity for Dependency Injection. So the current code is like this
ISomeInterface var = new SomeConcreteType(param);
...
0
votes
0
answers
229
views
Dependency injection integration with Unity.MVC, container.Resolve cannot be used with arguments of type
I'm trying to integrate Dependency Injection with Unity.MVC to my project. With the default configuration that Unity has, controllers works perfectly fine but I would like to implement DI en other ...
1
vote
0
answers
599
views
Does dotnet Maui Support Unity Container for Dependency Injection
I am converting my Xamarin Forms Application to dotnetMAUI. In Xamarin I've used Unity Container for dependency injection. Is Unity Container supported in dotnet MAUI?
1
vote
1
answer
59
views
Move container registrations to a new assembly with Prism.Unity.Forms
I'm currently using Prism with Unity in a Xamarin.Forms project.
I'm using
protected override void RegisterTypes(IContainerRegistry containerRegistry) {}
to register my classes in App.xaml.cs, but as ...
0
votes
1
answer
124
views
c# Converting a type to a generic
I'm trying to consolidate some code in an old .NET 4.0 project using UnityContainer for DI.
I have the following list of registrations, which are lazy loaded, with a constructor injection in a Unity ...
0
votes
0
answers
729
views
How to configure Unity container with ILogger<T> and EventLog?
I have the following problem: I am coding a Windows service using a console app project and Topshelf nuget . I am using Unity container to implement DI. Additionally, I would like to log the Windows ...
0
votes
1
answer
87
views
Unity- vs code error: if ($?) { dotnet run $Player_Movement }
Hi I am getting "cd "c:\Users\UMUT\Desktop\Unity Projects\Newest\Assets" ; if
($?) { dotnet run $Player_Movement }" message and I get this error message "Couldn't find a ...
0
votes
1
answer
48
views
Unity Container returning base type but wasn't before
I just got my unity config working, I started playing with web.config transformers and now it won't stop returning the base type.
I've stepped through the code to confirm the mapto value being picked ...