PDA

View Full Version : Configuration of IApplicationContext


Lado
03-29-2007, 08:54 PM
Hi All,

I am a new member of the forum. Our team at the place of work is trying to use Spring.Net in our developement and I've been reading the docuemtataion and playing with examples/tutorials provided therein.

I have a very simple web app to which I added project for my business object. I want to use DoI in the business object (project) tier as a proof of concepts for my team but I run to problem.

I basically defined my objects in App.config file in the same name space as my business object tier is, as follows:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<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">
<description></description>
<object id="SearchResult" type="MyAccount.DTO.UserSearchResultDTO, MyAccount.DTO">
<constructor-arg index="0" value="V1" />
<constructor-arg index="1" value="V2" />
<constructor-arg index="2" value="1234XYZ" />
</object>
</objects>
</spring>
</configuration>


Can somebody tell me why the IApplicationContext ctx = ContextRegistry.GetContext() return null calling it in a class in the business object tier?

Thanks

Lado -- Another Newbie

Nop
03-30-2007, 07:20 AM
Hi Lado.

You say that you tried to create web app with spring framework .net but you have created the configuration file for desktop app and have used configuration spring framework .net for the desktop. Is it typo error?

Best regards,
Nop

Lado
04-03-2007, 04:57 PM
Nop,

No, it is not a typo error. I will spring framework for web app.

Thanks

Lado

Nop
04-03-2007, 06:35 PM
Hi Lado.

If it not a typo error ;) , then you should to use configuration file of the spring context for web application. There are some differences from configuration files of desktop applications.

To get started see: Chapter 19. Spring.NET Web Framework (http://www.springframework.net/doc-latest/reference/html/web.html).

As a good example see: SpringAir solution.

If it is not enough to resolve your questions post it here :) .

Best regards,
Nop