I get an error when installing the service. I launch the console on behalf of the admin, enter the command: ServiceKisTopshelf.exe install. What could be the problem?
Can't install the service. I use the topshelf.
class Program
{
static void Main(string[] args)
{
var host = HostFactory.New(x => //1
{
x.StartAutomaticallyDelayed();
x.Service<StartProgram>(s => //2
{
s.ConstructUsing(name => new StartProgram()); //3
s.WhenStarted(sp => sp.Start()); //4
s.WhenStopped(sp => sp.Stop()); //5
});
x.RunAsLocalSystem(); //6???
x.SetServiceName("ServiceKisTopshelf"); //7
x.SetDisplayName("ServiceKisTopshelf"); //8
x.SetDescription("ServiceKIS Topshelf Host"); //9
x.UseNLog();
});
host.Run();
}
}
App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="DbProjectsContext" connectionString="data source=innc-mssqle01;initial catalog=db_projects;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />
</connectionStrings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Library" />
</assemblyBinding>
</runtime>
</configuration>