c# - Spring.NET ObjectDefinitionStoreException using assembly to store configuration files -
i learning spring.net, created class myapplication , library class mylib spring configuration files myapplication needs.
i retrieve metadata using:
iapplicationcontext ctx = new xmlapplicationcontext("assembly...");
i have 3 different xml files, 1 (springconfiguration.xml) imports 2 other. @ beginning of tries, spring configuration files @ root level of mylib. worked fine.
----- mylib -- properties -- references -- commonspring.xml -- buttonspring.xml -- springconfiguration.xml
then created folders in mylib store xml files , fails if use subfolders:
the following works:
----- mylib --properties --references --common --commonspring.xml --gui --buttonspring.xml --configuration --springconfiguration.xml
my springconfiguration.xml file then:
<?xml version="1.0" encoding="utf-8" ?> <objects xmlns="http://www.springframework.net"> <import resource="common/commonspring.xml"/> <import resource="gui/buttonspring.xml"/> </objects>
and retrieve context with:
iapplicationcontext ctx = new xmlapplicationcontext("assembly://mylib/mylib/configuration.springconfiguration.xml");
but if use subfolders fails:
----- mylib --properties --references --common --commonspring.xml --gui --specialbutton --buttonspring.xml --configuration --springconfiguration.xml
my springconfiguration.xml file then:
<?xml version="1.0" encoding="utf-8" ?> <objects xmlns="http://www.springframework.net"> <import resource="common/commonspring.xml"/> <import resource="gui/specialbutton/buttonspring.xml"/> </objects>
and retrieve context with:
iapplicationcontext ctx = new xmlapplicationcontext("assembly://mylib/mylib/configuration.springconfiguration.xml");
the error is:
{"error registering object defined in 'assembly [mylib, version=1.0.0.0, culture=neutral, publickeytoken=null], resource [mylib.configuration.springconfiguration.xml] @ line 5' : invalid relative resource location 'gui/specialbutton/buttonspring.xml' import object definitions from.\r\n<import resource=\"gui/specialbutton/buttonspring.xml\" xmlns=\"http://www.springframework.net\" />"}
i tried several syntaxes, looked in documentation , did not find solution. has idee of problem?
update ok found myself: correct syntaxe is:
<import resource="gui.specialbutton.buttonspring.xml"/>
then no errors raised anymore , work fine.
to let know here solution found: in springconfiguration.xml instead of refering spring configuration file nested in folders as:
<import resource="gui/specialbutton/buttonspring.xml"/>
one has write:
<import resource="gui.specialbutton.buttonspring.xml"/>
@marijn: thank explanation, understanding solution better finding ;)
Comments
Post a Comment