There is no suitable program type for the entry point

A recent update in RC2 nightly builds seems to have changed the way programs run. Starting with the update, I now receive an error message when I execute the following command.

// "commands": { // "web": "Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:1287" // } dnx --watch web 'Microsoft.AspNet.Server.Kestrel' does not contain a 'Program' type suitable for an entry point Stopped listening. 

The Startup.cs command compiles and has the following methods.

 public class Startup { public void ConfigureServices(IServiceCollection services, IHostingEnvironment env) { ... } public void Configure(IApplicationBuilder app, IApplicationLifetime lifetime) { ... } } 

What needs to be done to start the program from the last night ?

Here is an example that reproduces the problem. https://github.com/roydukkey/moist/tree/stackoverflow-34615917

sdk: v1.0.0-rc2-16357

+5
source share
2 answers

Aspnet / Hosting # 521 removed multiple entry points.

Previously, we had several entry points for web applications, including hosting ( Microsoft.AspNet.Hosting ), servers (for example, Microsoft.AspNet.Server.Kestrel ) and the application itself (for example, Startup.cs ). We removed the entry points to the hosting and servers, so the only entry point moving forward is the application. This will require an update for project.json , including setting emitEntryPoint to true in compilationOptions and setting commands to point to the build build. aspnet / Announcements # 131

To solve the problem, the commands parameters should point to the assembly, not to listing the previously installed server configuration. In addition, the emitEntryPoint parameter must be emitEntryPoint . Both of these settings are set using project.json .

  "compilationOptions": { "emitEntryPoint": true }, "commands": { - "web": "Microsoft.AspNet.Server.Kestrel" + "web": "Web" } 

Specific server configurations are now located in hosting.json . The following is an example configuration.

<Preview> <code> {"server": "Microsoft.AspNet.Server.Kestrel", "server.urls": "http: // localhost: 1234"} Code>

Please refer to roydukkey / moist / tree / stackoverflow-34615917 to view a workflow on all of this.

+2
source

You need to add a static class that has a static Main method. From there you must take it. As below:

 public class Program { public static void Main(string[] args) { var configuration = WebApplicationConfiguration.GetDefault(args); var application = new WebApplicationBuilder() .UseApplicationBasePath(Directory.GetCurrentDirectory()) .UseConfiguration(configuration) .UseStartup<Startup>() .Build(); application.Run(); } } 

Not sure if necessary, but you might need the following in project.json :

 "compilationOptions": { "emitEntryPoint": true } 

In the full version:

 { "version": "1.0.0", "compilationOptions": { "emitEntryPoint": true }, "dependencies": { "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc2-*", "Microsoft.AspNet.Hosting": "1.0.0-rc2-*" }, "frameworks": { "dnx451": {}, "dnxcore50": {} } } 
0
source

Source: https://habr.com/ru/post/1239912/


All Articles