阿加莎 RRSL 和 StructureMap 3.0
Agatha RRSL and StructureMap 3.0
我想将 Agatha RRSL 与我对 Agatha 的 IoC 容器的 StructureMap 3.0 包装器的实现一起使用。 Agatha 有带 StructureMap 2.6 的 NuGet 包,我不喜欢。
我从 copy/pasting 来自 Agatha.StructureMap source code 的代码开始,然后继续进行更改以使用 3.0 StructureMap。
我现在遇到的问题是我得到一个 StructureMapException
StructureMap.StructureMapBuildPlanException occurred
_HResult=-2146233088
_message=Unable to create a build plan for concrete type Agatha.Common.WCF.RequestProcessorProxy
HResult=-2146233088
IsTransient=false
Message=Unable to create a build plan for concrete type Agatha.Common.WCF.RequestProcessorProxy
new RequestProcessorProxy(InstanceContext, String endpointConfigurationName, String remoteAddress)
┗ InstanceContext = **Default**
String endpointConfigurationName = Required primitive dependency is not explicitly defined
String remoteAddress = Required primitive dependency is not explicitly defined
Source=StructureMap
Context=new RequestProcessorProxy(InstanceContext, String endpointConfigurationName, String remoteAddress)
┗ InstanceContext = **Default**
String endpointConfigurationName = Required primitive dependency is not explicitly defined
String remoteAddress = Required primitive dependency is not explicitly defined
Title=Unable to create a build plan for concrete type Agatha.Common.WCF.RequestProcessorProxy
StackTrace:
at StructureMap.Pipeline.ConstructorInstance`1.ToBuilder(Type pluginType, Policies policies) in c:\BuildAgent\work6e173a8ceccdca\src\StructureMap\Pipeline\ConstructorInstance.cs:line 83
InnerException:
在我看来,构造函数 StructureMap 认为它需要使用,但视图配置不正确,是具有多个参数的视图。实际上我需要它来使用无参数构造函数。
不过我认为我已经正确配置了构造函数。这是我用来为 RequestProcessorProxy 配置无参数构造函数的代码:
structureMapContainer.Configure(x => x.ForConcreteType<RequestProcessorProxy>().Configure.SelectConstructor(() => new RequestProcessorProxy()));
可能出了什么问题?
请注意,我是 StructureMap 和 Agatha 的新手,所以我可能误解了上述任何或所有内容...
我从来没有用过SelectConstructor
所以不知道如何让它工作但是如果你想让SM使用无参数构造函数那么你可以在解析具体类型时这样做:
var container =
new Container(
c => c.For<RequestProcessorProxy>().Use(() => new RequestProcessorProxy()));
或者在接口解析的时候像这样:
var container =
new Container(
c => c.For<IRequestProcessor>().Use(() => new RequestProcessorProxy()));
我对Agatha RRSL一点都不熟悉所以不知道我用的界面好不好
希望对您有所帮助!
我想将 Agatha RRSL 与我对 Agatha 的 IoC 容器的 StructureMap 3.0 包装器的实现一起使用。 Agatha 有带 StructureMap 2.6 的 NuGet 包,我不喜欢。
我从 copy/pasting 来自 Agatha.StructureMap source code 的代码开始,然后继续进行更改以使用 3.0 StructureMap。
我现在遇到的问题是我得到一个 StructureMapException
StructureMap.StructureMapBuildPlanException occurred
_HResult=-2146233088
_message=Unable to create a build plan for concrete type Agatha.Common.WCF.RequestProcessorProxy
HResult=-2146233088
IsTransient=false
Message=Unable to create a build plan for concrete type Agatha.Common.WCF.RequestProcessorProxy
new RequestProcessorProxy(InstanceContext, String endpointConfigurationName, String remoteAddress)
┗ InstanceContext = **Default**
String endpointConfigurationName = Required primitive dependency is not explicitly defined
String remoteAddress = Required primitive dependency is not explicitly defined
Source=StructureMap
Context=new RequestProcessorProxy(InstanceContext, String endpointConfigurationName, String remoteAddress)
┗ InstanceContext = **Default**
String endpointConfigurationName = Required primitive dependency is not explicitly defined
String remoteAddress = Required primitive dependency is not explicitly defined
Title=Unable to create a build plan for concrete type Agatha.Common.WCF.RequestProcessorProxy
StackTrace:
at StructureMap.Pipeline.ConstructorInstance`1.ToBuilder(Type pluginType, Policies policies) in c:\BuildAgent\work6e173a8ceccdca\src\StructureMap\Pipeline\ConstructorInstance.cs:line 83
InnerException:
在我看来,构造函数 StructureMap 认为它需要使用,但视图配置不正确,是具有多个参数的视图。实际上我需要它来使用无参数构造函数。
不过我认为我已经正确配置了构造函数。这是我用来为 RequestProcessorProxy 配置无参数构造函数的代码:
structureMapContainer.Configure(x => x.ForConcreteType<RequestProcessorProxy>().Configure.SelectConstructor(() => new RequestProcessorProxy()));
可能出了什么问题?
请注意,我是 StructureMap 和 Agatha 的新手,所以我可能误解了上述任何或所有内容...
我从来没有用过SelectConstructor
所以不知道如何让它工作但是如果你想让SM使用无参数构造函数那么你可以在解析具体类型时这样做:
var container =
new Container(
c => c.For<RequestProcessorProxy>().Use(() => new RequestProcessorProxy()));
或者在接口解析的时候像这样:
var container =
new Container(
c => c.For<IRequestProcessor>().Use(() => new RequestProcessorProxy()));
我对Agatha RRSL一点都不熟悉所以不知道我用的界面好不好
希望对您有所帮助!