Closed Mingism closed 10 years ago
Hi Kay!
You need to register the "Dependency" class as well.
container.Register<Foobar>();
container.Register<Dependency>();
Best regards
Bernhard Richter
On Sun, Dec 15, 2013 at 2:50 PM, Kay Tsar notifications@github.com wrote:
I am trying to run a simple test to see whether LightInject (NuGet package version 3.0.1.2) would be an appropriate solution for me, but I am getting an error on a basic test:
An unhandled exception of type 'System.InvalidOperationException' occurred in LightInject.dll
Additional information: Unable to resolve type: IoCContainer_Performance_Test.Program+Foobar, service name:
My code:
public class Foobar { Dependency _dependency; public Foobar(Dependency dependecy) { _dependency = dependecy; } }
public class Dependency { string test; public string Test { get { return test; } set { test = value; } } } static void LightInject() { // 1. Create a new container var container = new LightInject.ServiceContainer(); // 2. Register type(s) to the container container.Register<Foobar>(); for (int i = 0; i < 10000; i++) { Foobar store = container.GetInstance<Foobar>();// } }
Am I missing something in order to make it work properly?
— Reply to this email directly or view it on GitHubhttps://github.com/seesharper/LightInject/issues/52 .
You are absolutely right. Just out of interest, would you ever implement some kind of auto register of dependencies?
That is already implemented. You can register service by scanning one or many assemblies.
container.RegisterAssembly(typeof(Program).Assembly);
Best regards
Bernhard Richter
On Sun, Dec 15, 2013 at 3:36 PM, Kay Tsar notifications@github.com wrote:
You are absolutely right. Just out of interest, would you ever implement some kind of auto register of dependencies?
— Reply to this email directly or view it on GitHubhttps://github.com/seesharper/LightInject/issues/52#issuecomment-30607938 .
'Nuff said. I'll start reading the docs :+1:
:)
Sent from my iPhone
On 15. des. 2013, at 15:41, Kay Tsar notifications@github.com wrote:
'Nuff said. I'll start reading the docs [image: :+1:]
— Reply to this email directly or view it on GitHubhttps://github.com/seesharper/LightInject/issues/52#issuecomment-30608386 .
I am trying to run a simple test to see whether LightInject (NuGet package version 3.0.1.2) would be an appropriate solution for me, but I am getting an error on a basic test:
An unhandled exception of type 'System.InvalidOperationException' occurred in LightInject.dll
Additional information: Unable to resolve type: IoCContainer_Performance_Test.Program+Foobar, service name:
My code:
Am I missing something in order to make it work properly?