I'm developing an application in C#
and during development I came across the following error:
Inthefile:Settings.settings
thereisastring
thatstorestheusername.Apparentlythismaybetheproblem,butIneedthisstring
.Whatisthesolution?
Code:
namespaceMarcaBus.Properties{[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()][global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string Usuario {
get {
return ((string)(this["Usuario"]));
}
set {
this["Usuario"] = value;
}
}
}
}
In the file app.config
I added a line to force execution with level Administrator:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="MarcaBus.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<MarcaBus.Properties.Settings>
<setting name="Usuario" serializeAs="String">
<value />
</setting>
</MarcaBus.Properties.Settings>
</userSettings>
</configuration>