Maximum size for application settings?

Background: I had a large xml string in setup and it was not deserialized. XmlSerializer complained that it is not valid xml. When viewing a line in Project> Settings, it looked truncated.

I searched googled if there is a size limit for application parameters but nothing was found.

Then I tried to play it using dummydata generated by the following code:

[Test] public void DumpDummyData() { int n = 500; var s = new string('a', 100); using (FileStream stream = File.OpenWrite(@"C:\Temp\"+n+".txt")) { using (var writer = new StreamWriter(stream)) { for (int i = 0; i < n; i++) { writer.WriteLine( i +" " +s); } } } } 

The line is truncated on line 310 when inserting the contents of the file into the setting. Tried this in two different projects.

My question is, what is the limit for application settings size?

+7
c # application-settings
source share
2 answers

so I quickly checked

 using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine(Properties.Settings.Default.test.Length); Console.ReadKey(); } } } 

test parameter contains long text, more than 50,000 characters

it works.

what I did, I changed app.config manually, not from the settings of the properties of the visual studio.

I assume that the maximum default value is used on the settings screen. the maximum default value for a text field is 32,767 characters.

can you try your test again by changing app.config yourself?

do not use the visual studio properties settings screen.

+5
source share

I just had a test, and it looks like the settings string can contain exactly 32,767 bytes of text (2 bytes bytes). By and large, the coincidence is not to make it a limit value.

However, there is an XML document installation type (click Browse). This may be a way around the restrictions.

+1
source share

All Articles