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>
我的问题是,在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>
...全文
相关推荐
基于winform的spring.net+Nhibernate示例
这个框架使用Spring.NET-1.3.2和NHibernate-3.2.0,在mysql5.1上建了一个user表,字段请各位看映射文件啦(什么?你不懂什么是映射文件?)IDE用的是vs2008,.net框架用的是3.5。虽然配置得比较粗糙,好歹也算是个能跑的范例,在此抛砖引玉,希望各位有什么改进的建议也能在留言中提出。
学习了spring.net后写的小例子
最近学习了下spring.net的框架,有很多的不理解,通过blog的一些文章,写了个简单的小例子。
基于C#/.NET实现的Winform系统-图书馆管理系统
一整套的开发代码,从数据库的建库开始,到整个程序的完成,有效果图,有代码,适合进行开发实战,整个系统基于。net开发,需要的朋友自行下载
Ajax大赛_4
Ajax大赛_4,不看走宝
Ajax大赛_3
Ajax大赛_3,不看走宝


