c# winform spring.net

maoyongkang maoyongkang 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
各位:请帮忙!
我的问题是,在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>
...全文

相关推荐

评论 14
收藏 已收藏
分享
返回顶部
maoyongkang
C# 111,129 成员 642,540 内容