Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

System.Configuration: The entry '' has already been added.

$
0
0
Hello,

This is my first thread on MSDN forum. I have an issue with custom configuration. My custom application configuration looks like this:

1<?xml version="1.0" encoding="utf-8" ?> 
2<configuration> 
3  <configSections> 
4    <section name="ServerConfiguration.ServerConfig" type="ServerConfiguration.ServerConfig, ServerConfiguration"/>  
5  </configSections> 
6  <ServerConfiguration.ServerConfig> 
7    <Servers> 
8      <clearServers/> 
9      <Server name="localhost1" port="8080" protocol="net.tcp" hostname="localhost"/>  
10      <Server name="localhost2" port="8081" protocol="net.tcp" hostname="localhost"/>  
11    </Servers> 
12    <Regions> 
13      <clearRegions/> 
14      <removeRegion name=""/>  
15      <Region name="BASE" connectionString="XXXXXXXXXX" servicePath="D:\Services" clientPath="D:\">  
16        <Services> 
17          <clearServices/> 
18          <Service name="XXXXX"/>  
19        </Services> 
20      </Region> 
21    </Regions> 
22  </ServerConfiguration.ServerConfig> 
23</configuration> 

(Please Note: The above configuration schema is changed. Please find the new configuration schema somewhere in following replies. Thanks, - Jay)
The "Services" ConfigurationElementCollection has been nested in "Region" ConfigurationElement.
When I try to parse this configuration section, I get following error message:



1System.Configuration.ConfigurationErrorsException was unhandled     
2  BareMessage="The entry '' has already been added."    
3  Filename=""    
4  Line=0     
5  Message="The entry '' has already been added."    
6  Source="System.Configuration"    
7  StackTrace:     
8       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, Boolean getLkg, Boolean checkPermission)    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 TestApp.Form1.Button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\mmmm\My Documents\Visual Studio 2008\Projects\Server\TestApp\Form1.vb:line 6    at System.Windows.Forms.Control.OnClick(EventArgs e)    at System.Windows.Forms.Button.OnClick(EventArgs e)    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)    at System.Windows.Forms.Control.WndProc(Message& m)    at System.Windows.Forms.ButtonBase.WndProc(Message& m)    at System.Windows.Forms.Button.WndProc(Message& m)    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)    at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)    at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)    at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)    at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)    at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)    at System.Windows.Forms.Application.Run(Form mainForm)    at TestApp.Form1.Main() in C:\Documents and Settings\mmmm\My Documents\Visual Studio 2008\Projects\Server\TestApp\Form1.Designer.vb:line 2    at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)    at System.Threading.ThreadHelper.ThreadStart()     
9  InnerException:      
10    
11 




If I remove nesting of "Services" ConfigurationElementCollection from "Region" ConfigurationElement then it works!!! What is the problem?

Please help!

Thanks,
Jay

Viewing all articles
Browse latest Browse all 1710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>