Spring版本:2.0.0.40000 运行时:.NET 4.5
以此处显示的示例为例 www.springframework.net/.../objects.html以及API http://springframework.net/docs/1.3..../webframe.html - ContextHandler
我有以下
代码:
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
<sectionGroup name="child">
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
</sectionGroup>
</sectionGroup>
</configSections>
<spring>
<objects xmlns="http://www.springframework.net">
<import resource="assembly://ProjectDLL/Config/Spring.xml"/>
</objects>
<child>
<objects xmlns="http://www.springframework.net">
<object name="eventLog"
type="System.Diagnostics.EventLog, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
>
<constructor-arg type="string" name="logName" value="v1" />
<constructor-arg type="string" name="machineName" value="." />
<constructor-arg type="string" name="source" value="v1" />
</object>
</objects>
</child>
<context name="Parent">
<resource uri="config://spring/objects"/>
<context name="child">
<resource uri="config://spring/child/objects"/>
</context>
</context>
</spring>
调用
ContextRegistry.GetContext();
任何上下文名称的都会导致
消息---创建上下文'ChildContext'时出错:在对对象工厂进行后处理时出错。
我已经尝试了包括Child,ChildContext,Children在内的所有各种命名,但都会导致同样的错误。
在我的示例中,我使用包含我的对象()的资源文件,如果我不导入我自己的XML文件,它可以工作,但导入它意味着子工作不起作用。如果我在同一个xml文件中定义子项,我会得到“创建上下文'错误'父':有多个根元素”
我知道这很可能是一个配置问题,并希望得到任何帮助。
答案 0 :(得分:1)
由于没有完全理解我遇到的错误或原因,解决方法是使用“依赖”来启动。 spring xsd在这里定义了几个http://www.springframework.net/xsd/spring-objects.xsd