Closed Kumhy closed 3 years ago
@Kumhy
Not quite sure, I understand the question here. There is no formal support for Asp.net Core, but there are base demos that should get you started with Asp.Net Core - web-chromely.
A basic approach is to ensure it runs out of Chromely first. Also note the use of FreeTcpPort: https://github.com/chromelyapps/demo-projects/blob/1cac58ffb95098223e206043ad9748c3f80dcea1/web-chromely/web-chromely-mvc/Program.cs#L78
@mattkol Thank you very much, this makes my code work!
I am using Chromely + AspNetCore, This is my code: ` var appName = Assembly.GetEntryAssembly()?.GetName().Name; var webPort = ServerAppUtil.AvailablePort;
It is normal to use Application.Run for a window
Application.Run(new Union.FormJdLogin());
Using Chromely.Run a window is abnormal, and my incoming port is 5050, and the wrong port is 5051
2021-03-22T19:01:40.6826810+08:00 [FTL] Unable to start Kestrel. (fc6a528d) System.IO.IOException: Failed to bind to address http://127.0.0.1:5051: address already in use. ---> Microsoft.AspNetCore.Connections.AddressInUseException: 通常每个套接字地址(协议/网络地址/端口)只允许使用一次。 ---> System.Net.Sockets.SocketException (10048): 通常每个套接字地址(协议/网络地址/端口)只允许使用一次。 at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName) at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.Bind(EndPoint localEP) at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.Bind() --- End of inner exception stack trace --- at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.Bind() at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportFactory.BindAsync(EndPoint endpoint, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<>c__DisplayClass21_01.<<StartAsync>g__OnBind|0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context) --- End of inner exception stack trace --- at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context) at Microsoft.AspNetCore.Server.Kestrel.Core.LocalhostListenOptions.BindAsync(AddressBindContext context) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger logger, Func2 createBinding) at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication1 application, CancellationToken cancellationToken)