Learning While Aging

Invalid character in web.config comment causes “Unable to start debugging” error

When I tried to run a project today and got an “Unable to start debugging on the web server” error:


According to the suggestion in the error message, I ran the project without debugging, and it did provide more information about the error:

Parser Error Message: An XML comment cannot contain '--', and '-' cannot be the last character. Line 27, position 105.
Source File: ******\web.config    Line: 27

In my web.config file, I commented out one connection string which has the server name like this: sqlserver—1, it is the “—“ that caused the parse error. Apparently, the parse error says you cannot have “—“ in comment block. If it is outside comment block, then everything is ok.

The reason is that for compatibility, the string “–” (double-hyphen) MUST NOT occur within comments, according to the XML specification.

Therefore, if you have different connection strings in web.config file for testing and production which contains double-hyphen, and instead of commenting out the testing connection string when deploying application to production, you will need to delete it to avoid the above XML parse error.

0 0 vote
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x
Close Bitnami banner