c# winform spring.net
各位:请帮忙!
我的问题是,在winform中引用了spring框架,但一直报错误:未将对象引用设置到对象的实例!
不知道还有哪里配置错误了,请各位大侠帮忙看看那。
我的配置文件及代码如下
public partial class Form1 : Form
{
private HelloWorld helloWorldDAO;
public HelloWorld HelloWorldDAO
{
get { return helloWorldDAO; }
set { helloWorldDAO = value; }
}
public Form1()
{
InitializeComponent();
}
private void btn1_Click(object sender, EventArgs e)
{
//IApplicationContext context = ContextRegistry.GetContext();
label1.Text = helloWorldDAO.sayHello("maoyong");//这儿报错:未将对象引用设置到对象的实例!
//IApplicationContext context = ContextRegistry.GetContext();
//object o = context.GetObject("HelloWorldDAO");
//label1.Text = o.ToString();
}
}
配置文件如下:
<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="HelloWorldDAO" type="SpringHibernate.spring.HelloWorld" ></object>
<object id="form1" type="SpringHibernate.Form1">
<property name="HelloWorldDAO" ref="HelloWorldDAO" />
</object>
</objects>