[英]Can I create a ASP.NET Core Web Service with a Windows Forms GUI?
For testing purposes, I have an old.Net app with a WinForms GUI that is also a web service, ie, receives and responds to HTTP messages.出于测试目的,我有一个带有 WinForms GUI 的 old.Net 应用程序,它也是一个 web 服务,即接收和响应 HTTP 消息。 While running, it displays received messages and is interactive for querying additional info, etc. This was relatively easy to develop (years ago).
在运行时,它会显示收到的消息,并且可以交互查询其他信息等。这相对容易开发(几年前)。
I would like to convert this tool to ASP.NET Core.我想将此工具转换为 ASP.NET Core。 I have been able to convert a pure WinForms app with no problem, and can create a pure web service, but I have not found a way to combine the two.
我已经能够毫无问题地转换一个纯 WinForms 应用程序,并且可以创建一个纯 web 服务,但我还没有找到将两者结合起来的方法。 I need use
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
in the project file to get access to Winforms, but that causes all kinds of 'undefined' errors for things like IWebHostEnvironment, etc.我需要在项目文件中使用
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
来访问 Winforms,但这会导致 IWebHostEnvironment 等各种“未定义”错误。
In short, is there a way to create a web service that also has a local desktop GUI?简而言之,有没有办法创建一个也有本地桌面 GUI 的 web 服务? I think I need both "Microsoft.NET.Sdk.WindowsDesktop" and "Microsoft.NET.Sdk.Web".
我想我需要“Microsoft.NET.Sdk.WindowsDesktop”和“Microsoft.NET.Sdk.Web”。 (Note: I'm not worried about cross-platform portability.)
(注意:我不担心跨平台的可移植性。)
I've tried adding the following packages, but so far without success:我试过添加以下包,但到目前为止没有成功:
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.9" />
<PackageReference Include="System.Resources.Extensions" Version="4.7.1" />
</ItemGroup>
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<OutputType>WinExe</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.9" />
<PackageReference Include="System.Resources.Extensions" Version="4.7.1" />
</ItemGroup>
.
.
.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.