PDA

View Full Version : assembly configuration file


goody
03-09-2005, 08:47 PM
I have a project that I have embedded a configuration file in the assembly.
I have put all my unit tests for the project in a separate assembly. I am referencing the assembly with the embedded config file in my test project. In one of my unit tests I am trying to get an IApplicationContext object using the following:

IApplicationContext ctx = ConfigurationSettings.GetConfig("spring/context") as IApplicationContext;

My app.config file in my test project is as follows:
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.XmlApplicationContext, Spring.Core"/>
</sectionGroup>
</configSections>

<spring>
<context>
<resource uri="assembly://metalexis-netcommerce/metalexis.netcommerce.conf.spring/metalexis-domain.xml"/>
</context>
</spring>

The context is always null. What am I doing incorrectly. The dll is being referenced correctly because I can compile and call methods on it.

Thanks,

Matt

Mark Pollack
03-10-2005, 01:53 PM
Hi Matt,

You need to change what is in your configuration section handler to


<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
</sectionGroup>
</configSections>


It could be that some documentation is not correct - where did you run across an example the configuration you ended up using?

Cheers,
Mark

Anonymous
03-10-2005, 06:10 PM
Thanks Mark. I made that change and things still didn't work. Then it hit me, I'm actually trying to do this from a dll (not an exe or web app). I looked at another post and am now using the XmlObjectFactory. This will be just for individual layer testing. I will swith over to using the applicationcontext in the web.config file for the actual web app. Thanks for all the help. Sorry to waste your time. btw, the example that I used came from Chapter 3. 2.1 of the documentation on the web.

Thanks again,

Matt

Mark Pollack
03-10-2005, 06:18 PM
Hi Matt,

No problem. I just looked on the web at Section 3.2.1 (http://www.springframework.net/doc/reference/html/objects.html#objects-factory) but don't see any reference to the original mismatch you used for section handler. Probably just some cut-n-paste issue. Anyway, glad to hear you are up and running - let us know how Spring.NET works out for you and/or if there is anything we can do to improve docs/etc.

Cheers,
Mark