0

I'm trying to save some settings (such as my connection) string in a .config file. Most of the tutorials I see online on how to create a .config file state that I should manually add an existing one, but my program has already created one automatically and I have the following code inside it:

    <?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup><system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient"/>
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc812dsac44d"/>
    </DbProviderFactories>
  </system.data></configuration>

Now when I click the properties of my app.config file I get no error messages. But when I just click inside the text area I get the following 3 messages:

Could not find schema information for the attribute 'version'.
Could not find schema information for the attribute 'supportedRuntime'.
Could not find schema information for the attribute 'sku'.

So I created another app.config file and named it 'app2.config'. But when I copy the following code

      <appSettings>
    <add key="path226" value="Application.StartupPath" />
  </appSettings>

and try to retrieve the value by this code

MessageBox.Show(ConfigurationManager.AppSettings["path226"]);

I get a blank message box. If I try the same code within 'app.config' it works but I get the 3 error messages. I'm not sure whether I have to create my own app.config file or use the existing one. And If I have to use the existing one how can I solve my error ? Thanks for the help.

Kane
  • 1
  • 1
  • 1

1 Answers1

0

When you have your app.config open, go to the Properties window and click the ... on the Schemas property. In the window that opens, look for "DotNetConfig.xsd" in the 'File Name' column. Is it there? If so, make sure there is a check mark under the "Use" column. (You can right-click and 'Use selected schemas' if it's not)


Or try this answer: https://stackoverflow.com/a/14965640/1202807

  1. Right-click on the project icon in Solution Explorer and choose "Properties".
  2. Go to the "Application" tab and choose an earlier .NET target framework.
  3. Save changes.
  4. Go to the "Application" tab and choose the initial .NET target framework.
Community
  • 1
  • 1
Gabriel Luci
  • 38,328
  • 4
  • 55
  • 84