我有一个ASP.NET核心3.0Web应用程序(用来设置SignalR服务器),我想从一个.net核心控制台应用程序开始。但是,每当我将ASP.NET应用程序的输出类型设置为“控制台应用程序”并从一个简单的测试.net核心应用程序中引用它时,我在构建时就会得到以下错误:
Error: Program does not contain a static 'Main' method suitable for an entry point.
它还报告说找不到web应用程序的.dll文件,但我猜这是因为其他构建错误。但是,每当我将ASP.NET Core3.0Web应用程序的输出类型设
我有一个自我托管的.NET核心控制台应用程序。
web显示了ASP.NET核心的示例,但我没有web服务器。只是一个简单的命令行应用程序。
在控制台应用程序中可以这样做吗?
public static void Main(string[] args)
{
// I don't want a WebHostBuilder. Just a command line
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirecto
我有一个由控制台应用程序承载的WCF服务。客户端通过命名管道连接到服务。只有当客户机需要时,控制台才会被执行,而控制台在客户机完成后才会被杀死。
下面是启动和调用服务的代码:
Process hostProcess = Process.Start(info);
//make sure the service is up and running
//todo: find out a better way to check if the service is up and running.
Thread.Sleep(200);
EndpointAddress endpointAddress =
Windows自托管应用程序,当它启动时,它必须预加载数据,这可能需要60秒。因此,应用程序在启动时调用RequestAdditionalTime以避免超时错误。
这以前很好用。最近,我们升级到WindowsCore2.0,在Windows中自我托管,这种方法在Microsoft 中进行了描述。TargetFramework设置为net472
在WebHostService的派生类中,调用RequestAdditionalTime如下所示。
public class CustomWebHostService : WebHostService
{
public CustomWebHost