to transform my asp.net core in a Windows service I use function UseWindowsService() included in Microsoft.Extensions.Hosting.WindowsServices.
All seem to works well when I install it as a service but I noticed a strange problem: if in the appsettings.json there is a single '\' in any point of file, the service not start and return error 1053.
I tried to update to last version of the Microsoft.Extensions.Hosting.WindowsServices (5.0.1) but the problem persists.
Have you ever encountered this type of problem?
The things is that if my service doesn't start due to this problem on the configuration file I can't even log on file.
if the app gets a parsing error with appsettings.json it may fail to start or at the return parameter is invalid. as \ is a quote character in json, a single \ is probably an error. you probably want \\
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
None
0 Points
1 Post
UseWindowsService problem
Apr 07, 2021 03:54 PM|LArmstrong1985|LINK
Hi,
to transform my asp.net core in a Windows service I use function UseWindowsService() included in Microsoft.Extensions.Hosting.WindowsServices.
All seem to works well when I install it as a service but I noticed a strange problem: if in the appsettings.json there is a single '\' in any point of file, the service not start and return error 1053.
I tried to update to last version of the Microsoft.Extensions.Hosting.WindowsServices (5.0.1) but the problem persists.
Have you ever encountered this type of problem?
The things is that if my service doesn't start due to this problem on the configuration file I can't even log on file.
How can I solve?
Thank you in advance!
All-Star
58474 Points
15790 Posts
Re: UseWindowsService problem
Apr 07, 2021 09:40 PM|bruce (sqlwork.com)|LINK
if the app gets a parsing error with appsettings.json it may fail to start or at the return parameter is invalid. as \ is a quote character in json, a single \ is probably an error. you probably want \\
{
"filename": "c:\\temp"
}
Contributor
3040 Points
866 Posts
Re: UseWindowsService problem
Apr 12, 2021 06:53 AM|YihuiSun|LINK
Hi LArmstrong1985,
If you have to use special character in your json string, you can escape it using \ character.
In the rules of json, you must use \\ to escape the backslash every time.
Best Regards,
YihuiSun