.net 4.0 Spring.Net占位符异常

.net 4.0 Spring.Net占位符异常,.net-4.0,.net-3.5,spring.net,.net 4.0,.net 3.5,Spring.net,当我试图将我的项目从.NET3.5转换为.NET4时,我遇到了Spring.net最奇怪的问题 让我总结一下我们的架构: 项目A(不在我的控制下)有一个Sprint.Net配置,它引用了如下设置(configurationProvider.url): <constructor-arg name="Url" value="${configurationProvider.url}" /> 它显然没有在ProjectB配置文件中找到配置设置,尽管该文件存在并且包含值。 在3.5和4之间会

当我试图将我的项目从.NET3.5转换为.NET4时,我遇到了Spring.net最奇怪的问题

让我总结一下我们的架构: 项目A(不在我的控制下)有一个Sprint.Net配置,它引用了如下设置(configurationProvider.url):

<constructor-arg name="Url" value="${configurationProvider.url}" />
它显然没有在ProjectB配置文件中找到配置设置,尽管该文件存在并且包含值。 在3.5和4之间会有什么变化

完全例外:

Could not resolve placeholder 'configurationProvider.url'
<ConfigurationErrorsException d1p1:type="ConfigurationErrorsException">
 <ClassName>System.Configuration.ConfigurationErrorsException</ClassName>
 <Message>Error creating context 'spring.root': Error registering object with name 'configurationProvider' defined in 'assembly [ProjectA.Core, Version=0.0.0.88, Culture=neutral, PublicKeyToken=1b28b51fb20f454e], resource [ProjectA.Core.Framework.config] line 111' : Could not resolve placeholder 'configurationProvider.url'.</Message>
 <Data d1p1:type="IDictionary"/>
<InnerException d1p1:type="Exception">
 <ClassName>Spring.Objects.Factory.ObjectDefinitionStoreException</ClassName>
 <Message>Error registering object with name 'configurationProvider' defined in 'assembly [ProjectA.Core, Version=0.0.0.88, Culture=neutral, PublicKeyToken=1b28b51fb20f454e], resource [ProjectA.Core.Framework.config] line 111' : Could not resolve placeholder 'configurationProvider.url'.</Message>
 <Data d1p1:type="IDictionary"/>
 <InnerException d1p1:type="Exception"/>
 <HelpURL/>
 <StackTraceString> at Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer.ProcessProperties(IConfigurableListableObjectFactory factory, NameValueCollection props) at Spring.Objects.Factory.Config.PropertyResourceConfigurer.PostProcessObjectFactory(IConfigurableListableObjectFactory factory) at Spring.Context.Support.AbstractApplicationContext.ProcessObjectFactoryPostProcessors(IList objectFactoryPostProcessors) at Spring.Context.Support.AbstractApplicationContext.InvokeObjectFactoryPostProcessors() at Spring.Context.Support.AbstractApplicationContext.Refresh() at Spring.Context.Support.XmlApplicationContext..ctor(Boolean refresh, String name, Boolean caseSensitive, IApplicationContext parentContext, String[] configurationLocations) at Spring.Context.Support.XmlApplicationContext..ctor(String name, Boolean caseSensitive, String[] configurationLocations) at _dynamic_Spring.Context.Support.XmlApplicationContext..ctor(Object[] ) at Spring.Reflection.Dynamic.SafeConstructor.Invoke(Object[] arguments) at Spring.Context.Support.ContextHandler.RootContextInstantiator.InvokeContextConstructor(ConstructorInfo ctor) at Spring.Context.Support.ContextHandler.ContextInstantiator.InstantiateContext() at Spring.Context.Support.ContextHandler.InstantiateContext(IApplicationContext parentContext, Object configContext, String contextName, Type contextType, Boolean caseSensitive, String[] resources) at Spring.Context.Support.ContextHandler.Create(Object parent, Object configContext, XmlNode section)</StackTraceString>
 <RemoteStackTraceString/>
 <RemoteStackIndex>0</RemoteStackIndex>
 <ExceptionMethod>8 ProcessProperties Spring.Core, Version=1.3.0.20349, Culture=neutral, PublicKeyToken=65e474d141e25e07 Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer Void ProcessProperties(Spring.Objects.Factory.Config.IConfigurableListableObjectFactory, System.Collections.Specialized.NameValueCollection)</ExceptionMethod>
 <HResult>-2146232832</HResult>
 <Source>Spring.Core</Source>
 <WatsonBuckets d1p1:type="System.Byte"d1p1:includeArrayAttribute="true"/>
 <_resourceDescription>assembly [ProjectA.Core, Version=0.0.0.88, Culture=neutral, PublicKeyToken=1b28b51fb20f454e], resource [ProjectA.Core.Framework.config] line 111</_resourceDescription>
 <_objectName>configurationProvider</_objectName>
 </InnerException>
 <HelpURL/>
 <StackTraceString> at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult) at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSection(String configKey) at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName) at System.Configuration.ConfigurationManager.GetSection(String sectionName) at Spring.Util.ConfigurationUtils.GetSection(String sectionName) at Spring.Context.Support.ContextRegistry.InitializeContextIfNeeded() at Spring.Context.Support.ContextRegistry.GetContext() at ProjectA.Core.Controller.Initialise(String flavour) in d:\TeamCity8100\buildAgent\work\850180d7b576030f\Code\Src\ProjectA\Framework\Core\Controller.cs:line 238</StackTraceString>
 <RemoteStackTraceString/>
 <RemoteStackIndex>0</RemoteStackIndex>
 <ExceptionMethod>8 EvaluateOne System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a System.Configuration.BaseConfigurationRecord System.Object EvaluateOne(System.String[], System.Configuration.SectionInput, Boolean, System.Configuration.FactoryRecord, System.Configuration.SectionRecord, System.Object)</ExceptionMethod>
 <HResult>-2146232062</HResult>
 <Source>System.Configuration</Source>
 <WatsonBuckets d1p1:type="System.Byte"d1p1:includeArrayAttribute="true"/>
 <filename d1p1:type="Object"/>
 <line>0</line>
 <firstFilename d1p1:type="Object"/>
 <firstLine>0</firstLine>
 <count>0</count>
 </ConfigurationErrorsException>

System.Configuration.ConfigurationErrorsException
创建上下文“spring.root”时出错:注册在“assembly[ProjectA.Core,Version=0.0.0.88,Culture=neutral,PublicKeyToken=1b28b51fb20f454e],resource[ProjectA.Core.Framework.config]第111行”中定义的名为“configurationProvider”的对象时出错:无法解析占位符“configurationProvider.url”。
Spring.Objects.Factory.ObjectDefinitionStoreException
注册名为“configurationProvider”的对象时出错,该对象在“assembly[ProjectA.Core,Version=0.0.0.88,Culture=neutral,PublicKeyToken=1b28b51fb20f454e],资源[ProjectA.Core.Framework.config]第111行”中定义:无法解析占位符“configurationProvider.url”。
位于Spring.Objects.Factory.Config.PropertyPlaceHolderConfigure.ProcessProperties(IConfigurableListableObjectFactory,NameValueCollection props)的Spring.Objects.Factory.Config.PropertyResourceConfigure.PostProcessObjectFactory(IConfigurableListableObjectFactory工厂)Spring.Context.Support.AbstractApplicationContext.ProcessObjectFactoryPostProcessors(IList objectFactoryPostProcessors)的Spring.Context.Support.AbstractApplicationContext.InvokeObjectFactoryPostProcessors()的Spring.Context.Support.AbstractApplicationContext.Refresh()的Spring.Context.Support.XmlApplicationContext(布尔刷新、字符串名称、布尔区分大小写、IAApplicationContext parentContext、String[]configurationLocations)位于Spring.Context.Support.XmlApplicationContext..ctor(字符串名称、布尔区分大小写、String[]configurationLocations)位于_dynamic_Spring.Context.Support.XmlApplicationContext..ctor(对象[])在Spring.Context.Support.ContextHandler.RootContextInstancer.InvokeContextConstructor(ConstructorInfo-ctor)在Spring.Context.Support.ContextHandler.ContextInstancer.InstanceeContext()在Spring.Context.Support.ContextHandler.InstanceeContext()上调用(对象[]参数)(Spring.Context.Support.ContextHandler.Create(对象父对象、对象配置上下文、字符串contextName、类型contextType、布尔区分大小写、字符串[]资源)处的IAApplicationContext parentContext、对象配置上下文、XmlNode节)
0
8 ProcessProperties Spring.Core,版本=1.3.0.20349,区域性=neutral,PublicKeyToken=65e474d141e25e07 Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer Void ProcessProperties(Spring.Objects.Factory.Config.IConfigurableListableObjectFactory,System.Collections.Specialized.NameValueCollection)
-2146232832
弹簧芯
程序集[ProjectA.Core,Version=0.0.0.88,Culture=neutral,PublicKeyToken=1b28b51fb20f454e],资源[ProjectA.Core.Framework.config]第111行
配置提供程序
在System.Configuration.BaseConfigurationRecord.EvaluateOne(字符串[]键、SectionInput输入、布尔值isTrusted、FactoryRecord FactoryRecord、SectionRecord SectionRecord、Object parentResult)的System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord FactoryRecord、SectionRecord SectionRecord、Object parentResult、Boolean getLkg、Boolean getRuntimeObject、Object&result、Object&resultRuntimeObject)位于System.Configuration.BaseConfigurationRecord.GetSectionRecursive(字符串configKey、Boolean getLkg、Boolean checkPermission、Boolean getRuntimeObject、Boolean RequestISHER、Object&result、Object&resultRuntimeObject)位于System.Configuration.BaseConfigurationRecord.GetSectionRecursive(字符串configKey、Boolean getLkg、Boolean checkPermission、Boolean getRuntimeObject、Boolean RequestISHER、Object&result、Object&resultRuntimeObject)位于System.Configuration.BaseConfigurationRecord.GetSectionRecursive在System.Configuration.BaseConfigurationRecord.GetSection(String configKey,Boolean getLkg,Boolean checkPermission,Boolean getRuntimeObject,Boolean RequestsHere,Object&result,Object&resultRuntimeObject)中的System.Configuration.ClientConfigurationSystem.System.Configuration.InternalConfigSystem.GetSection中的(String configKey)(字符串configKey)位于Spring.Context.Support.ContextRegistry.InitializeContextIfRequired()的Spring.Context.Support.ConfigurationManager.GetSection(String sectionName)的Spring.Util.ConfigurationUtils.GetSection(String sectionName)的System.Configuration.ConfigurationManager.GetSection(String sectionName)的在d:\TeamCity8100\buildAgent\work\850180d7b576030f\Code\Src\ProjectA\Framework\Core\Controller.cs中:第238行
0
8 EvaluateOne System.Configuration,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a System.Configuration.BaseConfigurationRecord System.Object EvaluateOne(System.String[],System.Configuration.SectionInput,布尔值,System.Configuration.FactoryRecord,System.Configuration.SectionRecord,System.Object)
-2146232062
系统配置
0
0
0

我最终发现了问题。 我们在配置中使用PropertyPlaceHolderConfigure,并且从未设置“Order”属性。因此Spring对Order进行“排序”,但由于Order始终等于int.Max,因此订单输出是不确定的


向配置文件添加顺序修复了它。

我最终发现了问题。 我们在配置中使用PropertyPlaceHolderConfigure,并且从未设置“Order”属性。因此Spring对Order进行“排序”,但由于Order始终等于int.Max,因此订单输出是不确定的


将订单添加到配置文件中修复了它。

请发布相关配置部分或整个文件
<ConfigurationErrorsException d1p1:type="ConfigurationErrorsException">
 <ClassName>System.Configuration.ConfigurationErrorsException</ClassName>
 <Message>Error creating context 'spring.root': Error registering object with name 'configurationProvider' defined in 'assembly [ProjectA.Core, Version=0.0.0.88, Culture=neutral, PublicKeyToken=1b28b51fb20f454e], resource [ProjectA.Core.Framework.config] line 111' : Could not resolve placeholder 'configurationProvider.url'.</Message>
 <Data d1p1:type="IDictionary"/>
<InnerException d1p1:type="Exception">
 <ClassName>Spring.Objects.Factory.ObjectDefinitionStoreException</ClassName>
 <Message>Error registering object with name 'configurationProvider' defined in 'assembly [ProjectA.Core, Version=0.0.0.88, Culture=neutral, PublicKeyToken=1b28b51fb20f454e], resource [ProjectA.Core.Framework.config] line 111' : Could not resolve placeholder 'configurationProvider.url'.</Message>
 <Data d1p1:type="IDictionary"/>
 <InnerException d1p1:type="Exception"/>
 <HelpURL/>
 <StackTraceString> at Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer.ProcessProperties(IConfigurableListableObjectFactory factory, NameValueCollection props) at Spring.Objects.Factory.Config.PropertyResourceConfigurer.PostProcessObjectFactory(IConfigurableListableObjectFactory factory) at Spring.Context.Support.AbstractApplicationContext.ProcessObjectFactoryPostProcessors(IList objectFactoryPostProcessors) at Spring.Context.Support.AbstractApplicationContext.InvokeObjectFactoryPostProcessors() at Spring.Context.Support.AbstractApplicationContext.Refresh() at Spring.Context.Support.XmlApplicationContext..ctor(Boolean refresh, String name, Boolean caseSensitive, IApplicationContext parentContext, String[] configurationLocations) at Spring.Context.Support.XmlApplicationContext..ctor(String name, Boolean caseSensitive, String[] configurationLocations) at _dynamic_Spring.Context.Support.XmlApplicationContext..ctor(Object[] ) at Spring.Reflection.Dynamic.SafeConstructor.Invoke(Object[] arguments) at Spring.Context.Support.ContextHandler.RootContextInstantiator.InvokeContextConstructor(ConstructorInfo ctor) at Spring.Context.Support.ContextHandler.ContextInstantiator.InstantiateContext() at Spring.Context.Support.ContextHandler.InstantiateContext(IApplicationContext parentContext, Object configContext, String contextName, Type contextType, Boolean caseSensitive, String[] resources) at Spring.Context.Support.ContextHandler.Create(Object parent, Object configContext, XmlNode section)</StackTraceString>
 <RemoteStackTraceString/>
 <RemoteStackIndex>0</RemoteStackIndex>
 <ExceptionMethod>8 ProcessProperties Spring.Core, Version=1.3.0.20349, Culture=neutral, PublicKeyToken=65e474d141e25e07 Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer Void ProcessProperties(Spring.Objects.Factory.Config.IConfigurableListableObjectFactory, System.Collections.Specialized.NameValueCollection)</ExceptionMethod>
 <HResult>-2146232832</HResult>
 <Source>Spring.Core</Source>
 <WatsonBuckets d1p1:type="System.Byte"d1p1:includeArrayAttribute="true"/>
 <_resourceDescription>assembly [ProjectA.Core, Version=0.0.0.88, Culture=neutral, PublicKeyToken=1b28b51fb20f454e], resource [ProjectA.Core.Framework.config] line 111</_resourceDescription>
 <_objectName>configurationProvider</_objectName>
 </InnerException>
 <HelpURL/>
 <StackTraceString> at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult) at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSection(String configKey) at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName) at System.Configuration.ConfigurationManager.GetSection(String sectionName) at Spring.Util.ConfigurationUtils.GetSection(String sectionName) at Spring.Context.Support.ContextRegistry.InitializeContextIfNeeded() at Spring.Context.Support.ContextRegistry.GetContext() at ProjectA.Core.Controller.Initialise(String flavour) in d:\TeamCity8100\buildAgent\work\850180d7b576030f\Code\Src\ProjectA\Framework\Core\Controller.cs:line 238</StackTraceString>
 <RemoteStackTraceString/>
 <RemoteStackIndex>0</RemoteStackIndex>
 <ExceptionMethod>8 EvaluateOne System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a System.Configuration.BaseConfigurationRecord System.Object EvaluateOne(System.String[], System.Configuration.SectionInput, Boolean, System.Configuration.FactoryRecord, System.Configuration.SectionRecord, System.Object)</ExceptionMethod>
 <HResult>-2146232062</HResult>
 <Source>System.Configuration</Source>
 <WatsonBuckets d1p1:type="System.Byte"d1p1:includeArrayAttribute="true"/>
 <filename d1p1:type="Object"/>
 <line>0</line>
 <firstFilename d1p1:type="Object"/>
 <firstLine>0</firstLine>
 <count>0</count>
 </ConfigurationErrorsException>