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 unity3d instead (https://stackoverflow.com/tags/unity3d/info)!
3,898
questions
0
votes
0
answers
10
views
Legacy id not fetched. What should I do?
https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/GameKit_Guide/Users/Users.html#//apple_ref/doc/uid/TP40008304-CH8-SW6
I found a way to get teamPlayerId as ...
0
votes
0
answers
11
views
Animating Object in unity are change the position of another object
I have created an animation where the character is holding the gun.m
This is what my hierarchy
Player
-Camera Holder
---Camera
-Collider
---Arms
-----WeaponHolder
-------LHNode
-------RHNode
-------...
0
votes
0
answers
11
views
Draw line on canvas, but under text in an UI
How can i draw this line on my canvas and image, BUT under text?
so basically the render order should be this:
canvas
image
line
text
so text would be on top of every one of them.
right now i am ...
0
votes
1
answer
26
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 ...
0
votes
1
answer
24
views
How to register a unity IoC type in web.config so that it uses a specific constructor?
I've found several places that explain how to specify a constructor when registering a type in Unity IoC using source code, but what about in a configuration file? I'd like to register a type in my ...
0
votes
0
answers
32
views
How to inject dependencies of the same interface in some order? [duplicate]
interface I1{}
class Imp1: I1{}
class Imp2: I1{}
class User{
I1 var1;
I1 var2;
User(I1 v1, I1 v2){
var1 = v1;
var2 = v2;
}
}
So we have something like this, User has ...
1
vote
1
answer
28
views
Unity AR Animation doesn't convert to GameObject
Hello i'm coding an AR application but i have this type of error in Unity so i'm confused what i'm need to change. May you explain me how to solve this problem?
using System.Collections;
using System....
1
vote
1
answer
88
views
My game size is larger than 150 MB and I am struggling to upload on both platforms. (Unity)
I have a question regarding the upload of my game on Android playstore and iOS appstore. My game size is larger than 150 MB and I am struggling to upload on both platforms. I am writing this to you to ...
1
vote
1
answer
47
views
Unity Scene Window GUI Buttons are not rendering properly
I recently installed unity 2021.3.2f1, everything is fine, but the scene window buttons are not rendering properly, mainly there icons.
Is there a way to fix this issue?
NOTE: My PC does not have ...
0
votes
0
answers
18
views
Unity container creates 2 different instances
I don't have much exprience with unity so I may be doing something wrong.
I am using 3 interfaces: A and B, and C.
B depends on A.
C depends on both A and B.
For some reason, Unity creates 2 different ...
0
votes
1
answer
45
views
With Prism, can I use DependencyInjection by Microsoft rather than using either Prism.Unity or Prism.DryLoc?
My .NET 6 WPF application uses Prism.Wpf 8.1.97. I am also using Visual Studio Community 2022 (64bit). I am hesitant to use Prism.Unity because Unity has been deprecated. Because of my experience ...
-1
votes
1
answer
34
views
My object is faulty in Unity. How can i fix this?
The bar in the brick breaking game goes through the walls. I have tried many times to fix this but without success. Box collider, rigid boddy looks fine. My codes are at the bottom and I have uploaded ...
1
vote
1
answer
45
views
Extending Prism IContainerRegistry to register by name specifying constructor
I'm trying to migrate a Prism WPF application whitch is using Unity IoC container to use DryIoC container.
In a module I have the Unity container injected to register a class specifying the ...
1
vote
1
answer
40
views
DryIOC equivalent of Unity's PerResolveLifetimeManager
How to simulate Unity's PerResolveLifetimeManager with DryIoc?
That is, reuse within the current call to resolve, but not otherwise:
var a = container.Resolve<A>();
Assert( ReferenceEquals(a.B.D,...
1
vote
1
answer
81
views
Microsoft.Extensions.DependencyInjection auto resolve objects dependencies
Previously I was using Unity for dependency injection, and it automatically resolved dependency's for me that code looked something like this:
IUnityContainer UnityContainer = new UnityContainer();
...
0
votes
1
answer
52
views
Can I do a RegisterType in one project and Resolve this interface in another project using Unity Containers?
I have a VS solution A which contains an interface foo
public interface IFoo
{
//some methods
}
I have a solution B which implements this Interface
public class Bar : IFoo
{
//methods implemented ...
0
votes
1
answer
73
views
How to access DI framework Unity Container outside of composition root
I have integrated Unity container for my project snapp which has two folders named Commerce and Order. I have created constructor dependency injection for classes inside Commerce folder, say it has ...
0
votes
1
answer
57
views
Can I create global interceptor in Autofac?
In Unity, I can achieve global interceptor easily like this...
container.Configure<Interception>().AddPolicy("mylog")
.AddMatchingRule<SomeMatchingRule>() // always return ...
-2
votes
1
answer
31
views
Unity Container resolve calling same parameterized constructor twice
I'm using a unity container and I'm trying to resolve by passing the object to the parameterized constructor, I noticed the same constructor is called twice, the first time it takes appropriate values,...
0
votes
0
answers
80
views
How to use constructor dependency injection using unity in the test class
I am using Unity container to achieve the constructor DI in the console application. The dependency registration is done in the Main method of a program class.
All works fine but i am not able to ...
1
vote
0
answers
27
views
Is it possible to update registered singleton using unity container, c#?
I'm using unity container to implement a singleton design.
This is my code:
public class ExampleClass
{
public MyObj obj {get;private set;}
}
creating the singleton :
container.RegistryInstance(...
1
vote
1
answer
41
views
Is it possible to registry class , unity container ,c#
I'd like to use unity container to implement a singleton design.
for example:
create the singleton:
container.RegistryInstance<IClass>(new Class())
get the singleton instance:
container....
0
votes
0
answers
76
views
Video Player invisible in unity panel
I want to ask, when I play a video in the unity application panel, the video continues to run, but is not visible, but when I make the background of the panel transparent, the video becomes visible, ...
0
votes
0
answers
8
views
UnitConfig DI Containers. Referencing multiple instances
So I have an interface IState which, as part of that has a reference to the next State, so another IState. This creates a linked list type scenario. The issue I am having is setting this up in ...
0
votes
1
answer
2k
views
Adding Bearer Token to ASP.NET Web API that has Basic Authentication Attribute
I have an ASP.Net Web API 2 with BasicAuthenticationAttribute that is working as expected. In my application, there are different controllers and I want to add bearer token-based authentication to one ...
0
votes
0
answers
10
views
ContainerControlledLifetimeManager: one per Website or per AppPool?
I need a cache in my WebApi app that I register as a singleton using ContainerControlledLifetimeManager. I need the API exposed on two different sites that use the same AppPool. I need the changes ...
0
votes
3
answers
2k
views
How to solve "No cameras rendering" in Unity?
I am entirely new to Unity. I have a task to work with a tool in Unity. I'm not sure the "Game" is where I should work or the "Scene"? this is how my "Game" tab looks ...
1
vote
1
answer
125
views
Unity IOC configuration with json
In the app.config, it can look like below and the services and repositories are defined in a different file Unity.config. My question is, is it possible to do below in appsettings.json instead of app....
1
vote
1
answer
54
views
Migration from Prism 7 to Prism 8
I'm trying to upgrade from Prism 7.1.0.431 to 8.1.97 and I'm having several problems.
I think my biggest problem comes from replacing the "CommonServiceLocator.ServiceLocator.Current" with &...
1
vote
1
answer
106
views
Unity - Why isn't Resolve(ParameterOverride[]) using the expected constructor?
I want to use IoD with a class that implements an interface and has constructors with parameters.
The interface:
public interface IUsefulClass
{
string InterestingInfo { get; set; }
...
1
vote
1
answer
86
views
Unity Container VerificationException in TransientLifetimeManager on Azure DevOps
Our continuous integration builds on Azure DevOps just started having this problem running MSTest unit tests. Didn't update any of this code. Happening with Unity.Container.dll version 5.11.11.0 s ...
0
votes
0
answers
36
views
How to iterate through all views of all modules added to Unity catalog
I have a modular WPF/Prism/Unity application.
Modules are added to the catalog in the App code like
protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
{
moduleCatalog....
0
votes
0
answers
25
views
Unity Upgrade, objects were __TransparentProxy and are now Wrapped_XXX, unable to cast WCF Service to IChanel
I'm upgrading Unity inside an application from 5.2 to 5.11.
The code consists of a web application calling WCF services hosted by a windows service. The WCF calls are made through Unity. Interfaces ...
0
votes
0
answers
112
views
Unity Container - Register\Resolve classes without interface
I have created an Attribute Class that internally uses the Call Handler & Unity Interception to intercept the method and performs trace logging. I am using a unity container to Register and create ...
0
votes
0
answers
90
views
Unity IoC suddenly fails during runtime (Not WebApi)
This question is similar to Unity IoC suddenly fails during runtime but not exactly the same. That question relates to WebApi but our project is not WebApi (it's standard ASP.NET MVC v5).
The ...
1
vote
0
answers
32
views
Serilog used with Prism 8 and Injecting Microsoft.Extensions.Logging.ILogger
Using .Net 5 WPF, Serilog and PrismLibrary 8 with Unity
Can someone please guide me in the right direction so I can inject Microsoft.Extensions.Logging.ILogger into ViewModels etc.
I have found many ...
0
votes
0
answers
38
views
In the new Unity it is not possible to resolve a class if there is no explicit class registration, how to solve it?
We are a project from .Net Framework with Unity 2.1 to .Net Core with Unity 5.11 and there is 1 huge difference, which brings a lot of headache.
Example for Unity 2.1 (.Net Framework)
...
0
votes
0
answers
94
views
UnityContainer does not contain a defintion for Resolve
I have updated the depency injection framework 'Unity' to Version 5.11.10 in c# with .net 4.8.
Now the following code to resolve a class with the unity container show me an error.
using Unity;
...
var ...
0
votes
1
answer
53
views
Proper way of dispose a database context with unity
I am using unity and dependency injection and currently, I am a bit confused with the disposal of the connection.
I will give an example hoping that I explain it correctly :)
I have a controller that ...
0
votes
0
answers
88
views
Get an object from the Unity container where the interface is InterfaceA<InterfaceB> where InterfaceB is variable
I'm trying to make some C# code less verbose but I've run into a problem with using Unity to retrieve objects based on an interface like this:
public interface IMessagesHandler<T>
Leading ...
2
votes
0
answers
43
views
Prism.Unity.Forms 8.1 container.resolve stoped working after upgrade from version 7.2
I'm not a developer, but I managed to make an Xamarin.forms android app with prism 7.2, but recently I needed to add more features to the app and updated all NuGet packages, which updated Prism to ...
0
votes
0
answers
70
views
Opensource Unity interception, policy injection howto intercept on several types
We're using UnityContainer open source (https://github.com/unitycontainer) version 5.11.1 for DI and interception.
web.config (sample)
<configuration>
<configSections>
<...
1
vote
0
answers
73
views
Why are optional constructor parameters are not considered during dependency resolution
I have a class that implements ITranslator as below:
public SignalTranslator(
bool compress = false,
bool validate = false,
int maxThreads = 2)
{
// ctor logic
}
I register this implementation ...
0
votes
1
answer
25
views
Unity Container exception – You cannot have more than one dynamic module in each dynamic assembly in this version of the runtime
I've got a project that I need to Migrate from .NET Framework to .NET Core. After migrating it I've noticed an exception –
Unity.Exceptions.ResolutionFailedException HResult=0x80131500
Message=...
3
votes
0
answers
533
views
.net5.0 PRISM WPF application, how to use Microsoft.Exensions.Logging with Serilog as provider?
I've got a PRISM (8.1.97) WPF application running on .net5.0 with the unity container.
What I would like to do is to assign Serilog as my logging provider, but inject the usual Microsoft.Extensions....
0
votes
0
answers
39
views
How to resolve a registered type with Unity without the Container object?
In my productive code, I've got some code like the following. I would like to achieve, that in the method AddOrder, the instance which is currently created via new Connector() is created via Unity ...
0
votes
0
answers
78
views
How to do dependency override with Microsoft.Extensions.DependencyInjection
I am want to switch from Unity DI to Microsoft.Extensions.DependencyInjection. I am looking for equivalent syntax for DependencyOverride<T> in Unity DI.
container.Resolve<Module>(new ...
0
votes
0
answers
75
views
c# Unity 5.11.10 dependency injection StackOverflow exception
I have just upgraded Unity package to latest version and I am getting a possible circular dependency 'Stackoverflow' exception when I am registering 2 of my dto object mappers.
UnityConfig.cs
public ...
0
votes
0
answers
57
views
Create deps.json extension
I am trying to use NET5. And I use my old libraries (dll) with new code. In my old code I used UnityContainer with config file.
var unitySection = (UnityConfigurationSection)config.GetSection("...
0
votes
0
answers
65
views
Why the Unity Container Package with version >=5.8.13 tries to resolve System.Web.Http.Hosting.IHostBufferPolicySelector and 10 other classes
Why the Unity Container Package with version >=5.8.13 tries to resolve System.Web.Http.Hosting.IHostBufferPolicySelector and 10 other classes even if we dont explicitly call them in our code?
In my ...