You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Diagnostic() Extension and a run-time configured InjectionMethod the following exception will be thrown when trying to BuildUp an existing Object. "System.ArgumentException: Injected method SetDependencies() could not be matched with any public methods on type MyClassWithoutAttribute"
An alternatively usage of [InjectionMethod] Attribute however works as expected .
publicinterfaceISomeInterface{}publicclassSomeImpl:ISomeInterface{}publicclassMyClassWithAttribute{[InjectionMethod]publicvoidSetDependencies(ISomeInterfacesome){}}publicclassMyClassWithoutAttribute{publicvoidSetDependencies(ISomeInterfacesome){}}[TestClass]publicclassInjectionMethodIssue{[TestMethod]// Usage of run-time configuration with 'InjectionMethod' throws an exceptionpublicvoidTestWithoutAttributeAndDiagnostic(){varcontainer=newUnityContainer().AddExtension(newDiagnostic());container.RegisterType<ISomeInterface,SomeImpl>();container.RegisterType<MyClassWithoutAttribute>(newInjectionMethod("SetDependencies"));varinstance=newMyClassWithoutAttribute();container.BuildUp(instance);}[TestMethod]// Usage of [InjectionMethod] Attribute instead run-time config works (OK)publicvoidTestWithAttributeAndDiagnostic(){varcontainer=newUnityContainer().AddExtension(newDiagnostic());container.RegisterType<ISomeInterface,SomeImpl>();varinstance=newMyClassWithAttribute();container.BuildUp(instance);}[TestMethod]// Run-time config WITHOUT Diagnostic also works (OK)publicvoidTestWithoutAttributeAndWithoutDiagnostic(){varcontainer=newUnityContainer();container.RegisterType<ISomeInterface,SomeImpl>();container.RegisterType<MyClassWithoutAttribute>(newInjectionMethod("SetDependencies"));varinstance=newMyClassWithoutAttribute();container.BuildUp(instance);}}
The text was updated successfully, but these errors were encountered:
When using Diagnostic() Extension and a run-time configured InjectionMethod the following exception will be thrown when trying to BuildUp an existing Object.
"System.ArgumentException: Injected method SetDependencies() could not be matched with any public methods on type MyClassWithoutAttribute"
An alternatively usage of [InjectionMethod] Attribute however works as expected .
The text was updated successfully, but these errors were encountered: