Skip to main content

Questions tagged [unity-container]

The Unity Application Block (i.e. Unity) is a lightweight, extensible dependency injection container for .NET with support for interception. DO NOT USE THIS TAG TO REFER TO THE UNITY GAME ENGINE! Use unity-game-engine instead (https://stackoverflow.com/tags/unity-game-engine/info)!

unity-container
0 votes
0 answers
13 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 ...
user3497702's user avatar
0 votes
1 answer
51 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 ...
Code Vader's user avatar
0 votes
0 answers
34 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 (!!...
Dominique's user avatar
  • 17.1k
2 votes
1 answer
102 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 ...
Code Vader's user avatar
0 votes
1 answer
78 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" ...
Code Vader's user avatar
0 votes
0 answers
120 views

"startIndex cannot be larger than length of string": strange error during consuming Unity nuget package

I use Package Manager Console to install Unity package into my legacy projects in .NET Framework 4.5.2 that are placed in c:\%SOLUTION_BASE_PATH%\SomeFolder\SomeInnerFolder2\ParticularSolutionFolder. ...
Unnamed's user avatar
  • 198
1 vote
1 answer
59 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 ...
Brett's user avatar
  • 75
1 vote
2 answers
120 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 ...
Jean's user avatar
  • 37
0 votes
1 answer
33 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 ...
DucHo's user avatar
  • 124
0 votes
0 answers
49 views

Upgrade to Unity container throwing "COMException: Retrieving the COM class factory"

I have recently upgraded my project Unity Container to 5.11.10 version and below is the code using CommonServiceLocator; using Unity; using Unity.Injection; using Unity.Lifetime; using Unity....
Rollend Xavier's user avatar
1 vote
0 answers
70 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 ...
Arturio's user avatar
  • 446
0 votes
1 answer
37 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<...
pakerinjo's user avatar
2 votes
1 answer
159 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 { ...
pakerinjo's user avatar
0 votes
0 answers
34 views

When the ConfidentialClientApplication.AcquireTokenForClient() will return the same access token?

My project is using unity container and Microsoft.Identity.Client 4.22 which not support the cache methods. I register one class like AppTokenProvider as the singleton per container, and in the class, ...
feili's user avatar
  • 1
0 votes
0 answers
268 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 ...
Mahesh's user avatar
  • 410

15 30 50 per page
1
2 3 4 5
262