Spring.net step by step——初始坏境安装
一。在vs2010下引用Spring.net
使用nuget下载所需的spring.net 引用。点击tool-Nuget Package Manager-Manage Nuget Packages for Solution(注:没有安装nuget,点击toll-Extension Manager 安装Nuget Package Manager)。

二:选择需要安装的spring.net包。
Common.Logging.dll(必要)
Spring.Core.dll(必要)
Spring.Data.dll
Spring.Aop.dll(可选)
Spring.Data.NHibernate21.dll
Spring.Web.dll
注:nuget默认安装的spring.core是2.0以上的版本。需要commom.logging版本也需要2.0以上。默认安装1.2的版本。
解决办法:tool-Nuget Package Manager-package manager console
PM> Install-Package Common.Logging -Version 2.1.2
三:spring.net源码下载
可以从spring.net官网下载spring源码和demo、学习资料。
四:初始化IApplicationContext容器
使用spring.net 就需要初始化它的容器,才能对容器中的对象进行管理。类似于Unity。
在web.config或app.config添加自定义配置节点。在配置文件中要引入<objects xmlns="http://www.springframework.net"/>命名空间,否则程序将会无法实例化Spring.NET容器。
<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>
<!-- using embedded assembly configuration file
<resource uri="assembly://Spring.IocQuickStart.MovieFinder/Spring.IocQuickStart.MovieFinder/AppContext.xml"/>
-->
<!-- using section in App.config -->
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net" >
<description>An example that demonstrates simple IoC features.</description>
<object id="helloword" type="SpringStepByStep.HelloWold, SpringStepByStep">
</object>
</objects>
</spring>
IApplicationContext context = ContextRegistry.GetContext();//初始化容器
浙公网安备 33010602011771号