Hi Please can anyone help, I'm trying to get Service Fabric to Host a .Net Core Web API Restful service as a Guest Executable.
I'm guessing possibly incorrectly that I should be able to run the exe once I have done the full publish, but it fails when I do.
I have done the following...
- Ensured the main Web API assembly and all referenced .NET Core assemblies are set to x64 Targets
Set the Output type to be an exe and have a program.cs as below...
public static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>() .UseApplicationInsights() .Build(); host.Run(); }
Done the command line stuff...
dotnet restore dotnet publish -c release -r win10-x64
Made a Referenced to "Microsoft.AspNetCore.Server.Kestrel": "1.0.0" in Project.deps.json in the resultant win10-x64 publish folder.
However when I execute the thing directly the console window reports a problem with the StartUp Constructor, i.e. when performing builder.build.
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
//.AddServiceFabricConfig("Config") // Add Service Fabric configuration settings.
.AddEnvironmentVariables();
Configuration = builder.Build();
}
I feel close to getting this stuff working and have added a Service Fabric Guest Host project to host the exe, but needless to say the node fails with the error shown below...
Error event: SourceId='System.Hosting', Property='CodePackageActivation:Code:EntryPoint'.
There was an error during CodePackage activation.The service host terminated with exit code:2147516556
What am I doing wrong?