简体   繁体   English

我可以使用 Windows Forms GUI 创建 ASP.NET 核心 Web 服务吗?

[英]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.

相关问题 我可以将 ASP.NET Core MVC 添加到现有的 ASP.NET Web Z645024253191A381C36Z83CAE8 - Can I add ASP.NET Core MVC to existing ASP.NET Web Forms Application 以ASP.NET Web服务和Windows形式返回和读取对象 - Returning and reading objects in asp.net web service and windows forms 使用Asp.net Web表单创建与Windows相同的计算器 - Using Asp.net web forms to create a calculator same as windows 我可以将 asp.net web forms 应用程序部署到 Windows 7 笔记本电脑吗? - Can I deploy an asp.net web forms application to a Windows 7 laptop computer? 如何轻松地为自定义asp.net Web窗体控件创建模板? - How can I easily create templates for a custom asp.net Web Forms control? 如何从ASP.Net Web窗体应用程序中的Jquery安全地调用用于内部目的的Web服务(.asmx)? - How can I securely call a web service (.asmx) which is used for internal purposes from Jquery in a ASP.Net Web Forms application? 我可以将ASP.NET MVC与常规ASP.NET Web窗体一起使用吗 - Can I use ASP.NET MVC together with regular ASP.NET Web forms 我如何设置asp.net网络表单应用程序以在Windows 7上发送smtp电子邮件,以便进行测试? - How do i set up asp.net web forms app to send smtp email on windows 7 so i can test? 使用Windows应用程序中的表单身份验证的ASP.NET Web服务 - ASP.NET web service using forms authentication from a windows app ASP.NET网站+ Windows窗体应用程序+ WCF服务:客户端凭据 - ASP.NET Web Site + Windows Forms App + WCF Service: Client Credentials
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM