简体   繁体   English

参考 asp.net core web application from Z2D50972FECD376129545507F1062089Z core console application

[英]reference asp.net core web application from .net core console application

I have an ASP.NET core 3.0 web application (to setup a SignalR server) i want to start from a .net core console application. I have an ASP.NET core 3.0 web application (to setup a SignalR server) i want to start from a .net core console application. However, whenever i set the output type of the ASP.NET application to 'Console application' and reference it from a simple test .net core application i get the following error upon building:但是,每当我将 ASP.NET 应用程序的 output 类型设置为“控制台应用程序”并从简单的测试 .net 构建核心应用程序时引用它时,我都会收到以下错误:

Error: Program does not contain a static 'Main' method suitable for an entry point.

It also complains it cannot find the.dll file for the web application, but i guess that is because of the other build error.它还抱怨它找不到 web 应用程序的.dll 文件,但我猜这是因为其他构建错误。 Whenever i set the ASP.NET core 3.0 web application output type to 'Class library' however, everything builds just fine.每当我将 ASP.NET 核心 3.0 web 应用程序 output 类型设置为“类库”时,一切都构建得很好。 Only when i try to start the web application from the console application it only partially starts.只有当我尝试从控制台应用程序启动 web 应用程序时,它才部分启动。 I can clearly see the SignalR service and endpoint are being added, but when i try to connect a client to the SignalR server this isnt possible.我可以清楚地看到正在添加 SignalR 服务和端点,但是当我尝试将客户端连接到 SignalR 服务器时,这是不可能的。 What am i missing?我错过了什么? why cant i start the asp.net core web application from the .net core console application?为什么我不能从 .net 核心控制台应用程序启动 asp.net 核心 web 应用程序?

Good to note: when i start the web application from a main function within the web application itself (using the same code as i use in the console application) everything works just fine.需要注意的是:当我从 web 应用程序本身中的主 function 启动 web 应用程序时(使用与我在控制台应用程序中使用的相同的代码)一切正常

You cannot simply just reference the project.您不能简单地仅引用该项目。 It won't do anything, because it needs to actually be running.它不会任何事情,因为它需要实际运行。 You need to publish and deploy the ASP.NET Core app, and then access it via HTTP from your console app.您需要发布和部署 ASP.NET 核心应用程序,然后从控制台应用程序通过 HTTP 访问它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 asp.net 内核中的控制台应用程序和 Web 应用程序之间的区别 - Difference between a console application and Web application in asp.net core .NET标准库的ASP.NET Core 2 Web应用程序参考 - ASP.NET Core 2 Web Application Reference to .NET Standard Library .NET Core 控制台应用程序的 ASP.NET Core 配置 - ASP.NET Core configuration for .NET Core console application 从控制台应用程序启动ASP.NET Core 1应用程序 - Launching ASP.NET Core 1 app from console application 缺少“ASP.NET Core Web 应用程序(.NET Core)”模板 - missing “ASP.NET Core Web Application (.NET Core)” template C# Console application wont post large dataset to asp.net .net core 3.0 web api - C# Console application wont post large dataset to asp.net .net core 3.0 web api .Net Core框架ASP.Net Web应用程序的电子邮件发件人名称空间参考 - Email sender namespace reference for a .Net Core framework ASP.Net web application 将文件从 ASP.NET MVC 4.6 应用程序发布到 ASP.NET Core Web API - Posting a file from ASP.NET MVC 4.6 application to ASP.NET Core Web API ASP.NET核心Web应用程序(.NET Framework)TagHelper Intellisense - ASP.NET Core Web Application (.NET Framework) TagHelper Intellisense 处理身份验证/授权:ASP.NET Core Web 应用程序 => ASP.NET Core Web API => SQL - Handling authentication/authorization: ASP.NET Core Web Application => ASP.NET Core Web API => SQL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM