Search

ApplicationSettingsBase fails silently in special case with pre-generated serialization assembly by Martin S. Müller

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

1
0
Sign in
to vote
Type: Bug
ID: 777672
Opened: 1/28/2013 5:30:00 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
Please see "Steps to reproduce".

Note that the program works fine when no serialization dll is generated. And the program works fine when the declaration of StringList is moved before the declaration of MyStringCollection (because this changes the types contained in the serialization dll).

What I especially dislike with this issue is that the failure is completely silent - no errors, no exceptions.
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling Version

.NET Framework 4.5

Steps to reproduce

Create a new, empty console application with name "sgentest" and paste this code:

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;

class Program
{
static void Main(string[] args)
{
     Settings settings = new Settings();
     settings.S = new StringList();
     settings.S.Add("foo");
     settings.Save();
}

class Settings : ApplicationSettingsBase
{
     [UserScopedSetting]
     public StringList S { get { return (StringList) this["S"]; } set { this["S"] = value; } }
}
}

[Serializable]
public class MyStringCollection : StringCollection { }

[Serializable]
public class StringList : List<string> { }


Compile the code. Run:

sgen.exe /assembly:sgentest.exe

Make sure a file sgentest.XmlSerializers.dll has been generated. Run sgentest.exe.

Search the xml settings file that has been created.

Product Language

English

Operating System

Windows 7 SP1

Operating System Language

English

Actual results

The xml settings file contains an empty "S":

        <Program_x002B_Settings>
            <setting name="S" serializeAs="Xml">
                <value />
            </setting>
        </Program_x002B_Settings>

Expected results

The settings file contains a non-empty "S":

        <Program_x002B_Settings>
            <setting name="S" serializeAs="Xml">
                <value>
                    <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                        <string>foo</string>
                    </ArrayOfString>
                </value>
            </setting>
        </Program_x002B_Settings>
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 2/15/2013 at 1:45 PM
Hi Martin,
Thanks for your feedback. Since there is a workaround available right now, we have decided not to fix this in the current release. We will continue to monitor the customer feedback and reevaluate if more customers run into this.
Thanks.
Posted by Microsoft on 1/30/2013 at 12:55 AM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Martin S. Müller on 1/29/2013 at 3:36 AM
Well, maybe the MSDN should contain some more documentation where to find the settings files ;-)
Posted by Martin S. Müller on 1/29/2013 at 2:47 AM
The settings file is named user.config and stored in

%AppData%\<Company>\<ExeName>_Url_<some_hash<\<Version>

which is typically

C:\Users\<your user>\AppData\Local\<Company>\...
Posted by Microsoft on 1/29/2013 at 2:27 AM
Hi Martin S. Müller, i can't find the xml settings file. Please help. thanks.
Posted by Microsoft on 1/28/2013 at 5:52 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)
Sign in to post a workaround.