Error: Configuration system failed to boot

Asked

Viewed 1,298 times

2

I am developing an application in C# and during development I came across the following mistake:

Erro

In the archive: Settings.settings there’s a string which stores the user name. Apparently this may be the problem, but I need this string. What is the solution?

Code:

namespace MarcaBus.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 archive app.config i added a line to force execution with Administrator level:

<?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>

  • 2

    Hey, Marlon, what’s up? Prefer to post your code instead of posting images, usually when the question has only images it is closed. Hug!

  • Updated friend!

1 answer

1

The problem is with this line <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />.She’s in the wrong file. This tag is not understood by the element’s Xmlschema <configuration> app.config file(https://docs.microsoft.com/.../configuration-element)

This modification that you want to do (force use with administrative logon) must be done in the manifest file (app.manifest) of Assembly(https://docs.microsoft.com/.../assembly-manifest).

First you have to add a manifest file to your project:

  1. Right-click your project within Solution Explorer.
  2. In the context menu select "Add New Item".
  3. In the dialog box that will appear choose "File Manifesto"("Application Manifest File" if in English).

Go back to Solution Explorer and open the newly created manifest and search for and modify tags:

  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">

       <!-------------------- Adicione essa linha ----------------------->
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
       <!-------------------- Adicione essa linha ----------------------->

      </requestedPrivileges>
    </security>
  </trustInfo>

Probably inside the manifesto will be commented all possible requestedExecutionLevel:

<requestedExecutionLevel  level="asInvoker" uiAccess="false" />
<requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel  level="highestAvailable" uiAccess="false" />

Browser other questions tagged

You are not signed in. Login or sign up in order to post.