1

I have a WPF/C# application that I have created using Visual Studio 2012 to which I added a typed DataSet through the wizard.

Everything went smoothly, I could run everything over and over without any issues, until suddenly, I can't compile the solution anymore, I get the following errors inside the file App.config:

Error 3 Unrecognized escape sequence [...]\App.config 7 56 Contabilità Chiurlo v4 Warning 1 The 'configuration' element is not declared. [...]\App.config 2 2 Contabilità Chiurlo v4 Error 2 A namespace cannot directly contain members such as fields or methods [...]\App.config 1 1 Contabilità Chiurlo v4

The structure of the App.config file, which I have never edited manually, is the following:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
    </configSections>
    <connectionStrings>
        <add name="SOME NAME" connectionString="MY CONNECTION STRING"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
</configuration>

Where, of course, SOME NAME and MY CONNECTION STRING represents personal data, omitted for clarity.

My knowledge of this matter is close to zero, I have searched about similar issues but they all seem referred to somehow different situations. Some of them give a hint about a lack of xmlns specification, but I wouldn't know which one to add.

Looking back at my previous projects, the App.config file always had a similar structure, but now it is preventing me from compiling, while previously it probably only generated warnings.

What went wrong? How to fix it?

EDIT: The first error (marked as number 3), was caused by the absence of an escape character in my connection string, that had the structure C:\dir1\dir2 instead of C:\\dir1\\dir2. However, the other two errors (marked as 1 and 2), keep arising.

Erik Philips
  • 53,428
  • 11
  • 128
  • 150

2 Answers2

0

Try searching in the line and column specified in the error message for some invalid character. It points to your connection string in line 7, which you didn't provided.

Oscar
  • 13,594
  • 8
  • 47
  • 75
  • I have corrected the first error, turns out backslashes had no escaping backslash (strange, considering the wizard probably generated it that way). However, the other two errors are still unsolved. –  Mar 17 '14 at 23:39
0

The problem was exactly the same one reported (and solved) at this page.

I was just looking for the wrong keywords.

P.S. The URI C:\dir1\dir2 was, despite what appeared, correct: there was no "unrecognized escape sequence", and there was no need for escape characters. The corresponding error was merely a consequence of the other error. (namely "A namespace cannot directly contain members such as fields or methods")

Community
  • 1
  • 1