我可以在线搜索的所有示例都使用指定上下文定义的 App.Config 模式检索到
contextToGetSprungObjects = ContextRegistry.GetContext(contextname)
我想用
contextToGetSprungObjects = new XmlApplicationContext(sXmlFileName)
(我正在从另一个可执行文件(MsWord)调用一个 DLL(需要 Spring.net),因此 app.config 方法不可用)。我试着偷偷溜进 MyDll.dll.config.. 没有飞。在使用 XmlApplicationContext 方法从指定的 xml 文件中读取它时,我收到以下错误
{"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>"}
这使我相信这两种方法需要将它们的 xml 放在不同形状的瓶子中。我搜索了高低,但所需的 xml 架构让我望而却步。我能找到的所有东西都使用 X.exe.config 或 Web.config。有人可以为我指出 Spring.net 的有效 xml 上下文定义吗?
<spring>
<context>
<context name="MyApplication">
<resource uri="file://Resources/MyApplicationContext.xml"/>
</context>
</context>
</spring>
我认为这是我希望 Spring.net 读取的 app.config 的相关部分