PDA

View Full Version : Loading resource from separate app context file


jgalzic
03-27-2007, 12:45 AM
I'm new to Spring.Net and am trying to understand how I could specify a separate resource file name in the app.config. When I call IApplicationContext ctx = ContextRegistry.GetContext() from Main, I get the exception:

InnerException {"InputStream is null from Resource = [assembly [SpringTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null], resource [SpringTest.AppContext.xml]]"} System.Exception {Spring.Objects.Factory.ObjectDefinitionStoreExcep tion}

My app.config looks like:

<spring>
<context>
<resource uri="assembly://SpringTest/SpringTest/AppContext.xml"/>
</context>
</spring>

Contents of AppContext.xml:
<?xml version="1.0" encoding="utf-8" ?>

<objects xmlns="http://www.springframework.net">
<description>An example that demonstrates simple IoC features.</description>

<object name="MyMovieLister" type="SpringTest.MovieLister, SpringTest">
</object>

</objects>

I have the AppContext.xml as an embedded resource. Is there anything else I need to do to get this started?

Thanks,
Justin

Nop
03-27-2007, 06:42 AM
Hi Justin.
It is ok at first look. :(. I can't understand what is wrong.
Are you sure that AppContext.xml is an embedded resource?
I could simulate your exception when AppContext.xml was not an embeded resource.

Best regards,
Nop.

Bruno Baia
03-27-2007, 02:01 PM
Hi,

The assembly name looks good.

What is the namespace by default (look at project settings) ?
Where is located AppContext.xml ?

To get "assembly://SpringTest/SpringTest/AppContext.xml" working, there is two solutions :
- Namespace by default is SpringTest and AppContext.xml (embedded resource) is under the root directory.
- No namespace by default and AppContext.xml (embedded resource) is under the 'SpringTest' directory.


HTH,
Bruno

jgalzic
03-27-2007, 06:31 PM
Thank you all for your help. I was having this issue due to the following reasons:

-the AppContext.xml was actually named SpringTest.AppContext.xml
-the file really wasn't an embedded resource (some bug in VS 2005 that seemed to be reverting it).

Once I renamed SpringTest.AppContext.xml to just AppContext.xml, verified that my default namespace matched, and fixed up the embedded resource, I was able to load without errors.

Thanks again for all of your help.
Justin