Search

ConfigurationErrorsException thrown on service start when no whitespace between </value> and </setting> by David Nadle

Closed
as Won't Fix Help for as Won't Fix

10
0
Sign in
to vote
Type: Bug
ID: 352591
Opened: 6/23/2008 5:31:21 PM
Access Restriction: Public
0
Workaround(s)
4
User(s) can reproduce this bug
When a value node for applicationSettings is inserted by an installer process, whitespace or line breaks after the node are typically not inserted.

When I try to start my service with a setting formatted like:

<setting name="MySetting" serializeAs="String"><value>Foo</value></setting>

the service throws a TypeInitializationException with an inner ConfigurationErrorsException. If I add a space or line break after </value> the service starts.

Lack of whitespace does not make the XML invalid and should not impair the parsing of the config file.

This issue was discussed in a Nov 2007 MSDN forums thread but I can't find a corresponding bug report: http://forums.msdn.microsoft.com/en-US/netfxbcl/thread/2a0e81c2-6052-463b-9b90-f6bbd0cdca5a/
Details (expand)
Product Language
English

Version

.NET Framework 2.0 Service Pack 1
Operating System
Windows Server 2003
Operating System Language
English
Steps to Reproduce
Remove whitespace between </value> and </setting> in a Windows Service .exe.config file.
Actual Results
Service starts and stops, throwing TypeInitializationException with inner ConfigurationErrorsException.
Expected Results
Valid XML config file should parse without errors.
TAP Code (if applicable)
 
      You can indicate your satisfaction with how Microsoft handled this issue by completing this quick 3 question survey. [Details]

 

File Attachments
0 attachments
Sign in to post a comment.
Posted by JustinEzequiel on 7/1/2011 at 5:18 PM
Was banging my head for a couple of days on the exact same issue as Jon Parker's.
I have no problems using aspnet_regiis.exe to encrypt my Studio 2008 app.config files.
Studio 2010 however, gives me Unrecognized element 'setting'.
I would appreciate any workaround or better yet a fix.
Posted by Jon Parker on 6/16/2011 at 12:42 PM
So, for me this has been a problem with decrypting the settings using aspnet_regiis.exe

The fact that you won't fix it is a serious concern for me. There is no workaround for this because it's the encryption process that removes the whitespace.
Posted by Taz0 on 11/5/2009 at 7:04 AM
I've been banging my head on the wall over this issue for two full days. My issue was even harder to debug because my settings file is encrypted and so the whitespace difference is not immediately apparent by looking at the XML. Searching online for the exception's message didn't lead me to here because it's not mentioned anywhere on this page, so I hope this comment gets indexed so that other people can find the error and understand the root cause:

[System.Configuration.ConfigurationErrorsException] Unrecognized element 'setting'

This affected my WinForms application: I was manually encrypting the user settings node and since the default for the XmlDocument.PreserveWhitespace property is false, they were encrypted without whitespaces. When accessing the encrypted configuration file using ApplicationSettingsBase (a.k.a Settings.settings), the lack of whitespace threw the exception.
Posted by Microsoft on 4/13/2009 at 10:44 PM
Thanks for your feedback on the .NET Framework!

Customer feedback is a critical part of a successful, impactful product release. Unfortunately another part is the reality of schedules and the need to get the bits into production. We have evaluated the issue that you reported and it does not meet the criteria to be addressed in this release. This evaluation is carefully done and considers many aspects including fix cost, breaking changes, globalization, performance, etc.

Many customers have found it useful to discuss issues like this in the forums (http://forums.microsoft.com/msdn/default.aspx?siteid=1) where Microsoft and other members of the community can suggest workarounds.

Before we even begin work on the next release of the NET Framework release where we can make changes like this one we will devote time to addressing the top issues/suggestion (in terms of number of votes, lack of workarounds, etc). So please do continue to vote for this item if it is causing issues.

Please keep the feedbacks coming.

Thanks,
UIFx Team
Posted by Microsoft on 6/26/2008 at 4:25 AM
Thanks for your feedback. We are escalating this bug to the product unit who works on that specific feature area. The team will review this issue and make a decision on whether they will fix it or not for the next release.

Thank you,
Visual Studio Product Team
Posted by Microsoft on 6/24/2008 at 5:43 AM
Thank you for your feedback, We are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)

If at any time your issue is closed unsatisfactorily, you may edit your issue via Connect and change the status to “Active.”

Thank you,
Visual Studio Product Team
Sign in to post a workaround.