My .NET Core 5.0 web application is not working after publishing it. Error "Unhandled exception. System.TypeInitializationException: "
Your connection string is escaped improperly.
Change this
"ConnectionString": "Server=1**1\Manageengine;Database=ServiceDesk;Trusted_Connection=True;User ID=ad-***\tmsdb.****;Password=$***"
to this
"ConnectionString": "Server=1**1\\Manageengine;Database=ServiceDesk;Trusted_Connection=True;User ID=ad-***\\tmsdb.****;Password=$***"
You need an extra \
for two parts of that string. The \M
and the \t
need to be \\M
and \\t
respectively.
JSON Parsing Issue - 'S' is an invalid escapable character within a JSON
In your ConnectionStrings. DefaultConnString
field, you're escaping S
(before SQLExpress;
). As the error suggests, you can't do that.
You can fix this by adding another escape character (backslash, \
) in front of the pre-existing one. Backslashes are escapable characters and the end result will be the wanted one, you'll get one backslash in that position.
Upgraded to ASP.NET Core 3.1, getting error about System.Text.Json
The trick that solves 90% of the issues since Visual Studio 2002 ;-)
manually delete all bin and obj folders in your solution.
Error parsing JSON for network server name
It's hard to know exactly what your problem is without seeing the exact error message, but this sequence of characters at the beginning of your string looks wrong:
\"\\\E
Since \
is used to escape the following character, then \"
will be interpreted as "
and \\
will be interpreted as \
. This leaves \E
which is not a valid escape sequence. I also don't think you need \"
at the beginning or end of your string, unless the code that uses this value expects the string to be "wrapped" with double quotes.
Try the following, and see if that resolves your parsing error:
"ExportLocation": "\\\\Eservername.domain.com\\filefolder\\subfolder\\"
More information on other valid escape sequences can be found here.
Related Topics
Sorting String Values Without Using Any Method/Function
How to Combine Values of Several Lists into One in C#
How to Delete Records Between Two Dates in Bulk
How to Set Autoincrement Ids in Unit Test
C# Best Way to Run a Function Every Second, Timer VS Thread
How to Ignore Convert to Nullable in Lambda Expressions
Trying to Add Spaces Between Characters in a String in C#
Access Variables/Functions from Another Component
Copy Files With Authentication in C#
Asp.Net Core - Swashbuckle Not Creating Swagger.Json File
How to Count Rows Within Entityframework Without Loading Contents
Lambda Where Id Does Not Exist in Another List
C# File.Delete, File Being Used by Another Process
Using Enum and | as Dictionary Key
Controlling Datetime Parameter Formatting in Webapi 2
How to Loop Through Each and Every Row, Put Value in Gridview Column Cells