What is the format of the xml context definition file that the XmlApplicationContext (sFileName) will read?

All examples that I can search the web use App.Config mode to define the definition of the context obtained with

contextToGetSprungObjects = ContextRegistry.GetContext(contextname)

      

I want to use

contextToGetSprungObjects = new XmlApplicationContext(sXmlFileName)

      

(I am calling a DLL (Spring.net required) from another executable (MsWord), so the app.config method is missing). I tried to sneak into MyDll.dll.config .. didn't fly. Using the XmlApplicationContext method to read it from the specified XML file, I get the following error:

{"Error registering object with name '' defined in 'file [D:\\Work\\Seven\\WordAutomation\\ContentControls\\WordDocument1\\bin\\debug\\MyWPFPlotPopup.dll.config]' : There is no parser registered for namespace ''\r\n<configSections><sectionGroup name=\"spring\"><section name=\"context\" type=\"Spring.Context.Support.ContextHandler, Spring.Core\" /></sectionGroup><section name=\"log4net\" type=\"log4net.Config.Log4NetConfigurationSectionHandler, log4net\" /></configSections>"}

      

This leads me to think that these two approaches need their xml in a bottle of different shape. I have searched high and low but the schema for the xml I need eludes me. All I can find is using X.exe.config or Web.config. Can anyone point me to correct xml context validation for Spring.net?

<spring>
    <context>
        <context name="MyApplication">
            <resource uri="file://Resources/MyApplicationContext.xml"/>
        </context>
    </context>
</spring>

      

I think this is the relevant section of the app.config that I want Spring.net to read

0


source to share


2 answers


Spring.NET docs - good exercise with pain

Have you checked the Basics - Containers and Objects section of the reference documents? IMHO chapters 5.2.1 Configuration Metadata and 5.2.2 Instantiating a Container are pretty clear about what you were trying to achieve. What were your pain points? We look forward to receiving your suggestions for improvement!



I'd also like to invite you to post Spring for .NET Related Questions on our forum - rather answer your questions.

funny, Erich

+2


source


Finally, this obstacle became clear. The XmlApplicationContext does not read the intermediate xml mapping in app.config ... it reads the content specified as a resource element directly. It will not read the app.config format which is used by the ContextRegistry class in Spring.net. Spring.net docs is a good exercise with pain.

context = new XmlApplicationContext("file://Resources/MyApplicationContext.xml");

      



where this xml is as follows.

<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">
  <object id="Wilma" type="WhatIsSpring.Wilma, WhatIsSpring"/>
  <object id="Fred" type="WhatIsSpring.Fred, WhatIsSpring">
    <property name="TheDependency" ref="Wilma"/>
  </object>
</objects>

      

+2


source







All Articles