using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spring.Context;
using Spring.Context.Support;namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            IApplicationContext context = ContextRegistry.GetContext();
            Hello hello = (Hello)context.GetObject("hello");
            System.Console.Out.WriteLine(hello.HelloWord);
            System.Console.In.Read();
        }
    }
}<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <sectionGroup name="spring">
      <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
    </sectionGroup>
  </configSections>  <spring>
    <context>
      <resource uri="config://spring/objects"/>
    </context>
    <objects xmlns="http://www.springframework.net">
      <object id="hello" type="HelloWorld.Hello">
        <property name="HelloWord" value="Hello!Welcome to Spring.Net Word!"/>
      </object>
    </objects>
  </spring>
</configuration>
为什么总是报异常呢???
总是说Spring.Context.Support.ContextRegistry”的类型初始值设定项引发异常
郁闷一天了哪位大侠帮帮忙啊!!

解决方案 »

  1.   

    在线等~~~!!!!我用的是vs2010 跟这个有关系么?我引用的也是4.0的Spring.Core.dll ,一运行就报这个异常郁闷。。
      

  2.   

    http://hi.baidu.com/ybhjj/blog/item/6fd358f8efb09703d8f9fdc6.html
      

  3.   

    请确认Spring.NET的面向的.NET Framework的版本,是否与你当前应用程序一致。我的将应用程序是 .NET Framework 4.0,引用的 Spring.NET 是.NET Framework2.0的,结果和你一样出错。