I am working with some sort a small RESTful layer to expose (to the internet) the local application data in a host machine.
It behaves like a typical web service that listens incoming request to a port. I wrote it with ASP .NET Core 3.1 with a tiny layer wrapper called Carter, it has also a DLL / COM Reference (used for querying the data).
I followed the following guides to configure it as a windows service, publish the service, and then to create it.
- https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/windows-service?view=aspnetcore-5.0&tabs=visual-studio
- https://dotnetcoretutorials.com/2019/12/21/hosting-an-asp-net-core-web-app-as-a-windows-service-in-net-core-3/
I did successfully created a service but it won't start and windows is showing this error dialog.
I am relatively new to .NET development and I am not sure what's wrong here or how to fix this.
Program.cs
namespace Adapter
{
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
public class Program
{
public static void Main(string[] args)
{
var host = Host.CreateDefaultBuilder(args)
.UseWindowsService()
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>())
.Build();
host.Run();
}
}
}
Startup.cs
namespace Adapter
{
public class Startup
{
public Startup()
{
// load the env values during start up
new Env().Load();
}
public void ConfigureServices(IServiceCollection services)
{
// interface binding for dependency injection
services.AddSingleTonServices();
// carter and routing services
services.AddCarter();
services.AddRouting();
services.AddHostedService<Worker>();
}
public void Configure(IApplicationBuilder app)
{
app.UseRouting();
app.UseEndpoints(builder => builder.MapCarter());
}
}
}
BTW My project is running correctly when you run or debug it in visual studio.
Any help or idea will be much appreciated.
Error 1053: The service did not respond to the start or control request in a timely fashion is the problem caused by the timeout after the particular request.
This error has many variants.You can read this article to try to solve:
[Fix] Error 1053: The service did not respond to the start or control request in a timely fashion
Alternatively, to resolve this issue, you can download the following registry fix for your operating system:
Windows Search “Error 1053” Fix for Windows 7
Windows Search “Error 1053” Fix for Windows 8.1
Windows Search “Error 1053” Fix for Windows 10