首页 新闻 会员 周边

关于spring.net的问题

0
悬赏园豆:5 [已关闭问题] 关闭于 2012-05-13 09:22

使用spring.net生成对象时,出现一下错误:

Cannot resolve type [CreateObjects.Domain.StudentDao,CreateObjects.Domain] for object with name 'StudentDao' defined in file [E:\.NET Study\Spring.NET学习笔记\Spring.NET Study\SpringNetLesson2\CreateObjectsBySpringDotNet\Objects.xml] line 8

配置文件Objects.xml如下:

View Code
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.net
        http://www.springframework.net/xsd/spring-objects.xsd">

  <!--构造器-->
  <object id="StudentDao" type="CreateObjects.Domain.StudentDao,CreateObjects.Domain">
    
  </object>
  
</objects>

客户端代码如下:

View Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CreateObjects.Domain;
using Spring.Context;
using Spring.Context.Support;
using Spring.Objects.Factory;

namespace CreateObjectsBySpringDotNet
{
    class Program
    {
        static void Main(string[] args)
        {
            //使用构造器创建对象
            Console.WriteLine("使用构造器创建对象:");

            string[] xmlFiles = new string[]
            {
              "file://../../Objects.xml"
            };

            IApplicationContext iContext=new XmlApplicationContext(xmlFiles);


            IObjectFactory iObjectFactory = iContext;
            Console.WriteLine(iContext.GetObject("StudentDao").ToString());

        }
    }
}

找了好久都没找到错误的原因,希望大家帮忙看看!谢谢啦

小桥屋檐下的主页 小桥屋檐下 | 初学一级 | 园豆:191
提问于:2012-05-05 12:30
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册