why is this config file wrong

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Feb 2006
Posts: 399
Reputation: chris5126 is an unknown quantity at this point 
Solved Threads: 14
chris5126 chris5126 is offline Offline
Posting Whiz

why is this config file wrong

 
0
  #1
Apr 22nd, 2009
Hi,

I wish to add the following to my web.config file:

  1. <appSettings>
  2. <add key="networkDrive" value="C:\test"/>
  3. </appSettings>
But everytime I add it i get the following error:

  1. Sections must only appear once per config file
I looked in the file to see if it appeared more than once but couldn't find it I did a search for appSettings it returned three results, two were included in the statement I just added and the third was

  1. </sectionGroup></sectionGroup></sectionGroup></configSections>
  2.  
  3. <appSettings/>

However I cant see where it was opened. If I take out the code I add the project compiles without error. Please help whole config file below!


  1. <?xml version="1.0"?>
  2. <!--
  3. Note: As an alternative to hand editing this file you can use the
  4. web admin tool to configure settings for your application. Use
  5. the Website->Asp.Net Configuration option in Visual Studio.
  6. A full list of settings and comments can be found in
  7. machine.config.comments usually located in
  8. \Windows\Microsoft.Net\Framework\v2.x\Config
  9. -->
  10. <configuration>
  11. <configSections>
  12. <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  13. <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  14. <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
  15. <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  16. <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
  17. <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
  18. <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
  19. <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/></sectionGroup></sectionGroup></sectionGroup></configSections>
  20.  
  21. <appSettings/>
  22. <connectionStrings>
  23. <add name="sitehealthConnectionString" connectionString="Data Source=CHRIS-LAPTOP\PROJECT;Initial Catalog=sitehealth;Integrated Security=True" providerName="System.Data.SqlClient"/>
  24. </connectionStrings>
  25. <appSettings>
  26. <add key="networkDrive" value="C:\test"/>
  27. </appSettings>
  28. <system.web>
  29. <authentication mode="Windows"/>
  30. <authorization>
  31. <deny users="?"/>
  32. </authorization>
  33. <identity impersonate="true" userName="service_sitehealth" password="VFK279"/>
  34. <!--
  35. Set compilation debug="true" to insert debugging
  36. symbols into the compiled page. Because this
  37. affects performance, set this value to true only
  38. during development.
  39. -->
  40. <compilation debug="true">
  41. <assemblies>
  42. <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  43. <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  44. <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  45. <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  46. <add assembly="System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  47. <add assembly="System.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  48. <add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  49. <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  50. <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies>
  51. </compilation>
  52. <!--
  53. The <customErrors> section enables configuration
  54. of what to do if/when an unhandled error occurs
  55. during the execution of a request. Specifically,
  56. it enables developers to configure html error pages
  57. to be displayed in place of a error stack trace.
  58.  
  59. <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
  60. <error statusCode="403" redirect="NoAccess.htm" />
  61. <error statusCode="404" redirect="FileNotFound.htm" />
  62. </customErrors>
  63. -->
  64. <pages buffer="true" enableViewState="true">
  65. <controls>
  66. <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  67. <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></controls></pages>
  68. <httpHandlers>
  69. <remove verb="*" path="*.asmx"/>
  70. <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  71. <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  72. <add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></httpHandlers>
  73. <httpModules>
  74. <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></httpModules>
  75. </system.web>
  76.  
  77. <system.codedom>
  78. <compilers>
  79. <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
  80. <providerOption name="CompilerVersion" value="v3.5"/>
  81. <providerOption name="WarnAsError" value="false"/></compiler>
  82. <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
  83. <providerOption name="CompilerVersion" value="v3.5"/>
  84. <providerOption name="OptionInfer" value="true"/>
  85. <providerOption name="WarnAsError" value="false"/></compiler></compilers></system.codedom>
  86. <system.webServer>
  87. <validation validateIntegratedModeConfiguration="false"/>
  88. <modules>
  89. <remove name="ScriptModule"/>
  90. <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></modules>
  91. <handlers>
  92. <remove name="WebServiceHandlerFactory-Integrated"/>
  93. <remove name="ScriptHandlerFactory"/>
  94. <remove name="ScriptHandlerFactoryAppServices"/>
  95. <remove name="ScriptResource"/>
  96. <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  97. <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  98. <add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></handlers></system.webServer>
  99. <runtime>
  100. <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  101. <dependentAssembly>
  102. <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
  103. <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly>
  104. <dependentAssembly>
  105. <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
  106. <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly></assemblyBinding></runtime></configuration>
If my post helped add to my rep!
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 68
Reputation: achristov is an unknown quantity at this point 
Solved Threads: 5
achristov's Avatar
achristov achristov is offline Offline
Junior Poster in Training

Re: why is this config file wrong

 
0
  #2
Apr 22nd, 2009
<appSettings/>
<!-- other stuff here... -->
<appSettings>
<add key="networkDrive" value="C:\test"/>
</appSettings>
This is what is wrong. You have two appSettings sections: an empty one (the above) and your modified one. You should keep only one of them.
If you find this answer satisfactory, please add to my reputation.
Last edited by achristov; Apr 22nd, 2009 at 8:38 am.
Alexander Christov,
www.achristov.info
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 399
Reputation: chris5126 is an unknown quantity at this point 
Solved Threads: 14
chris5126 chris5126 is offline Offline
Posting Whiz

Re: why is this config file wrong

 
0
  #3
Apr 22nd, 2009
Thats what i thought initally but if you look there is never <appSettings> for the first one otherwise I would have just added my key to that section!
If my post helped add to my rep!
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 68
Reputation: achristov is an unknown quantity at this point 
Solved Threads: 5
achristov's Avatar
achristov achristov is offline Offline
Junior Poster in Training

Re: why is this config file wrong

 
0
  #4
Apr 22nd, 2009
Nevermind! You still have two appConfig sections. The fact that the first one does not have child nodes does not mean that the sections are getting merged or otherwise processed by the configuration manager. Once it encounters the first section it processes it and decides that the job's finished. You offer it extra work with the second section so it complains.
Last edited by achristov; Apr 22nd, 2009 at 9:03 am.
Alexander Christov,
www.achristov.info
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 399
Reputation: chris5126 is an unknown quantity at this point 
Solved Threads: 14
chris5126 chris5126 is offline Offline
Posting Whiz

Re: why is this config file wrong

 
0
  #5
Apr 22nd, 2009
hi,

Thanks and I understand that but how do i fix the problem if I add:

<add key="networkDrive" value="C:\test"/>

Before the <appSettings/> I get an error Unrecognized configuration section add. if I add

<appSettings>
<add key="networkDrive" value="C:\test"/>

I get The 'appSettings' start tag on line 20 does not match the end tag of 'configuration'. Line 106, position 123.

I just dont get it!
If my post helped add to my rep!
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 68
Reputation: achristov is an unknown quantity at this point 
Solved Threads: 5
achristov's Avatar
achristov achristov is offline Offline
Junior Poster in Training

Re: why is this config file wrong

 
0
  #6
Apr 22nd, 2009
You should have
<appSettings><add key="networkDrive" value="C:\test"/></appSettings>
in your web.config. The line
<add key="networkDrive" value="C:\test"/>
is allowed only within appSettings section. The section appSettings should be one and only one in the whole config file.
Alexander Christov,
www.achristov.info
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC