<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>
</configSections>
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
<object id="mySayHello" type="IocInCSharp.SayHello, SayHello">
<property name="HelloGenerator">
<ref object="myCnHelloGenerator"/>
</property>
</object>
<object id="myEnHelloGenerator" type="IocInCSharp.EnHelloGenerator, HelloGenerator"/>
<object id="myCnHelloGenerator" type="IocInCSharp.CnHelloGenerator, HelloGenerator"/>
</objects>
</spring>IApplicationContext ctx = ConfigurationSettings.GetConfig("spring/context") as IApplicationContext; ISayHello sayHello = (ISayHello)ctx.GetObject("mySayHello");
sayHello.SayHelloTo("zhenyulu");
Console.ReadKey();
为什么总是报异常:
创建 spring/context 的配置节处理程序时出错: 调用的目标发生了异常
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
</sectionGroup>
</configSections>
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
<object id="mySayHello" type="IocInCSharp.SayHello, SayHello">
<property name="HelloGenerator">
<ref object="myCnHelloGenerator"/>
</property>
</object>
<object id="myEnHelloGenerator" type="IocInCSharp.EnHelloGenerator, HelloGenerator"/>
<object id="myCnHelloGenerator" type="IocInCSharp.CnHelloGenerator, HelloGenerator"/>
</objects>
</spring>IApplicationContext ctx = ConfigurationSettings.GetConfig("spring/context") as IApplicationContext; ISayHello sayHello = (ISayHello)ctx.GetObject("mySayHello");
sayHello.SayHelloTo("zhenyulu");
Console.ReadKey();
为什么总是报异常:
创建 spring/context 的配置节处理程序时出错: 调用的目标发生了异常
解决方案 »
- 关于tabcontrol的问题
- C#.net中listview添加第二列中的内容
- 如何在DataGridView派生每个单元格里面都带有一个TextBox和一个CheckBox的列?
- 大虾救命,如何把一个从数据库提取出来的Object转换成为byte[].分不够再加
- 引用Left,Mid出错,急!!
- 搞不订了,怎么给Treeview追加节点(windows)
- 请教各位,ie web controls控件问题!!调试没有问题,但是预览页面的时候,出现如下错误,请问如何?
- 100分求邮件发送的简单问题,高手请入内....
- c#web程序中页面之间传递页面参数,用什么好!而且安全,稳定!希望各种高手给出意见,谢谢!
- 菜鸟问题?(它困惑我好久了)
- SHDocVw.InternetExplorer的问题,郁闷中
- 执行ExecuteNonQuery出现“无效操作。连接被关闭。”
http://msdn.microsoft.com/zh-cn/library/system.configuration.configurationmanager.getsection.aspx