error storing < and > characters in app.config file in C#
Solution 1
Just change the <
and >
to <
and >.
Solution 2
If you indeed need to put that query in the app.config, you can put it inside a CDATA section or you can escape those characters with <
and >
Solution 3
First, if you're storing SQL in the app.config you're probably doing something wrong. As @ChrisBint said, you should probably put this in an embedded resource file instead.
That being said, you should be able to correct the problem by replacing any special characters with a proper entity:
< ... <
> ... >
" ... "
Solution 4
Store the SQL in a resource file rather than the app.config.
Solution 5
(greater-than character) use ">"
Must be used for an attribute value, but > is acceptable as the content of an element as long as < does not precede it.
< (less-than character) - use "<"
Must be used for an attribute value, but < is acceptable as the content of an element as long as > does not follow it.
source - http://msdn.microsoft.com/en-us/library/ms748250.aspx
dnyan86
Updated on June 25, 2022Comments
-
dnyan86 almost 2 years
I want to store a sql query in app.config file which has < and > characters but file shows error 'expecting >' , have you come across this problem ?