.Net Framework 4.6.1+版本的Winform程序开启Web服务,支持Http webapi

这篇具有很好参考价值的文章主要介绍了.Net Framework 4.6.1+版本的Winform程序开启Web服务,支持Http webapi。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

背景

在很久以前为了满足需求,已经开发了一款winform程序,并且是4.6.1版本的,如今为了和第三方对接,需要在这个winform上提供WebAPI的接口。因为第三方的程序是一份没有源码的程序。

思路

方法1

  • 网上有很多自写web服务的功能,个人觉得过于麻烦,而且还要考虑一些路由规则什么的,太难了

方法2

  • 使用iis或者nginx提供服务,一个web程序和一个winform程序实现通信,需要做两个程序,还要交互,麻烦

方法3(本文使用的方法)

考虑4.6.1 版本刚好支持了netcore,所以可以将kestrel服务集成到winform中,直接提供webapi服务

实现

在winform程序中引入几个nuget包

Microsoft.AspNetCore  Version="2.1.7"
Microsoft.AspNetCore.Mvc  Version="2.1.3"

在使用nuget引入的时候会将关联的全部引入进来,完整的packages.config文件如下

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Microsoft.AspNetCore" version="2.1.7" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Antiforgery" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Authentication.Abstractions" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Authentication.Core" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Authorization" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Authorization.Policy" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Connections.Abstractions" version="2.1.3" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Cors" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Cryptography.Internal" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.DataProtection" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.DataProtection.Abstractions" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Diagnostics" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Diagnostics.Abstractions" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.HostFiltering" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Hosting" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Hosting.Abstractions" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Hosting.Server.Abstractions" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Html.Abstractions" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Http" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Http.Abstractions" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Http.Extensions" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Http.Features" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.HttpOverrides" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.HttpsPolicy" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.JsonPatch" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Localization" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Mvc" version="2.1.3" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Mvc.Abstractions" version="2.1.3" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Mvc.ApiExplorer" version="2.1.3" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Mvc.Core" version="2.1.3" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Mvc.Cors" version="2.1.3" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Mvc.DataAnnotations" version="2.1.3" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Mvc.Formatters.Json" version="2.1.3" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Mvc.Localization" version="2.1.3" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Mvc.Razor" version="2.1.3" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Mvc.Razor.Extensions" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Mvc.RazorPages" version="2.1.3" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Mvc.TagHelpers" version="2.1.3" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Mvc.ViewFeatures" version="2.1.3" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Razor" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Razor.Design" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Razor.Language" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Razor.Runtime" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.ResponseCaching.Abstractions" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Routing" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Routing.Abstractions" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Server.IISIntegration" version="2.1.7" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Server.Kestrel" version="2.1.3" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Server.Kestrel.Core" version="2.1.3" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Server.Kestrel.Https" version="2.1.3" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions" version="2.1.3" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets" version="2.1.3" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.WebUtilities" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.CodeAnalysis.Analyzers" version="1.1.0" targetFramework="net461" />
  <package id="Microsoft.CodeAnalysis.Common" version="2.8.0" targetFramework="net461" />
  <package id="Microsoft.CodeAnalysis.CSharp" version="2.8.0" targetFramework="net461" />
  <package id="Microsoft.CodeAnalysis.Razor" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.CSharp" version="4.5.0" targetFramework="net461" />
  <package id="Microsoft.DiaSymReader.Native" version="1.7.0" targetFramework="net461" />
  <package id="Microsoft.DotNet.PlatformAbstractions" version="2.1.0" targetFramework="net461" />
  <package id="Microsoft.Extensions.Caching.Abstractions" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.Caching.Memory" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.Configuration" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.Configuration.Abstractions" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.Configuration.Binder" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.Configuration.CommandLine" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.Configuration.EnvironmentVariables" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.Configuration.FileExtensions" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.Configuration.Json" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.Configuration.UserSecrets" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.DependencyInjection" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.DependencyModel" version="2.1.0" targetFramework="net461" />
  <package id="Microsoft.Extensions.FileProviders.Abstractions" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.FileProviders.Composite" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.FileProviders.Physical" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.FileSystemGlobbing" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.Hosting.Abstractions" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.Localization" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.Localization.Abstractions" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.Logging" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.Logging.Abstractions" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.Logging.Configuration" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.Logging.Console" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.Logging.Debug" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.ObjectPool" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.Options" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.Options.ConfigurationExtensions" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.Primitives" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Extensions.WebEncoders" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Net.Http.Headers" version="2.1.1" targetFramework="net461" />
  <package id="Microsoft.Win32.Registry" version="4.5.0" targetFramework="net461" />
  <package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" />
  <package id="Newtonsoft.Json.Bson" version="1.0.1" targetFramework="net461" />
  <package id="System.AppContext" version="4.3.0" targetFramework="net461" />
  <package id="System.Buffers" version="4.5.0" targetFramework="net461" />
  <package id="System.Collections" version="4.3.0" targetFramework="net461" />
  <package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net461" />
  <package id="System.Collections.Immutable" version="1.5.0" targetFramework="net461" />
  <package id="System.ComponentModel.Annotations" version="4.5.0" targetFramework="net461" />
  <package id="System.Console" version="4.3.0" targetFramework="net461" />
  <package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net461" />
  <package id="System.Diagnostics.DiagnosticSource" version="4.5.1" targetFramework="net461" />
  <package id="System.Diagnostics.FileVersionInfo" version="4.3.0" targetFramework="net461" />
  <package id="System.Diagnostics.StackTrace" version="4.3.0" targetFramework="net461" />
  <package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net461" />
  <package id="System.Dynamic.Runtime" version="4.3.0" targetFramework="net461" />
  <package id="System.Globalization" version="4.3.0" targetFramework="net461" />
  <package id="System.IO.Compression" version="4.3.0" targetFramework="net461" />
  <package id="System.IO.FileSystem" version="4.3.0" targetFramework="net461" />
  <package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net461" />
  <package id="System.IO.Pipelines" version="4.5.3" targetFramework="net461" />
  <package id="System.Linq" version="4.3.0" targetFramework="net461" />
  <package id="System.Linq.Expressions" version="4.3.0" targetFramework="net461" />
  <package id="System.Memory" version="4.5.2" targetFramework="net461" />
  <package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net461" />
  <package id="System.Reflection" version="4.3.0" targetFramework="net461" />
  <package id="System.Reflection.Metadata" version="1.6.0" targetFramework="net461" />
  <package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net461" />
  <package id="System.Runtime" version="4.3.0" targetFramework="net461" />
  <package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net461" />
  <package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net461" />
  <package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net461" />
  <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net461" />
  <package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net461" />
  <package id="System.Security.AccessControl" version="4.5.0" targetFramework="net461" />
  <package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net461" />
  <package id="System.Security.Cryptography.Cng" version="4.5.0" targetFramework="net461" />
  <package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net461" />
  <package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net461" />
  <package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net461" />
  <package id="System.Security.Cryptography.Xml" version="4.5.0" targetFramework="net461" />
  <package id="System.Security.Permissions" version="4.5.0" targetFramework="net461" />
  <package id="System.Security.Principal.Windows" version="4.5.1" targetFramework="net461" />
  <package id="System.Text.Encoding" version="4.3.0" targetFramework="net461" />
  <package id="System.Text.Encoding.CodePages" version="4.3.0" targetFramework="net461" />
  <package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net461" />
  <package id="System.Text.Encodings.Web" version="4.5.0" targetFramework="net461" />
  <package id="System.Threading" version="4.3.0" targetFramework="net461" />
  <package id="System.Threading.Tasks" version="4.3.0" targetFramework="net461" />
  <package id="System.Threading.Tasks.Extensions" version="4.5.1" targetFramework="net461" />
  <package id="System.Threading.Tasks.Parallel" version="4.3.0" targetFramework="net461" />
  <package id="System.Threading.Thread" version="4.3.0" targetFramework="net461" />
  <package id="System.ValueTuple" version="4.3.0" targetFramework="net461" />
  <package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net461" />
  <package id="System.Xml.XDocument" version="4.3.0" targetFramework="net461" />
  <package id="System.Xml.XmlDocument" version="4.3.0" targetFramework="net461" />
  <package id="System.Xml.XPath" version="4.3.0" targetFramework="net461" />
  <package id="System.Xml.XPath.XDocument" version="4.3.0" targetFramework="net461" />
</packages>

新建一个Startup类(叫什么名字都行)

代码如下

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace 测试一个winform
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseMvc();
        }
    }
}

修改Program文件

增加一个启动web的方法,并且在main函数中将方法启动
为了在后面能够调用form1,所以我还将form1的对象改成了静态的,代码如下

using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 测试一个winform
{
    internal static class Program
    {
    //声明一个静态的
        public static Form1 mainForm;
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
        //启动
            Task.Run(() => { CreateWebHostBuilder(new string[] { }).Build().Run(); }); 
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            mainForm = new Form1();
            Application.Run(mainForm);
        }

//新增加的代码
        public static IWebHostBuilder CreateWebHostBuilder(string[] args)
        {
            return WebHost.CreateDefaultBuilder(args)
                .UseUrls("http://0.0.0.0:7001", "https://0.0.0.0:7002")
                   .UseStartup<Startup>();
        }
    }
}

创建controller

文件结构如下
winform调用webapi,.net,前端,http

代码内容如下

using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using 测试一个winform;

namespace 测试一个winform集成web.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class ValuesController : ControllerBase
    {
        // GET api/values
        [HttpGet]
        public ActionResult<IEnumerable<string>> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET api/values/5
        [HttpGet("{id}")]
        public ActionResult<string> Get(int id)
        {

            Program.mainForm.Message(id.ToString());
            return "value";
        } 
    }
}

运行效果(打开浏览器,输入如下地址)

winform调用webapi,.net,前端,http

修改地址,调用get方法引起winform变动

winform调用webapi,.net,前端,http

winform中的message方法


        public void Message(string message)
        {
            //MessageBox.Show(message);
            this.Invoke(new Action(() => { button1.Text = message; }));
         
        }

关于配置端口和地址请查看文章

https://blog.csdn.net/iml6yu/article/details/100692488

https://blog.csdn.net/iml6yu/article/details/100692488

完整代码下载

https://download.csdn.net/download/iml6yu/87726309

如果无法下载可以 QQ和我说 (复制下面给内容到浏览器地址栏,按下回车 tencent://message/?uin=646007589&Site=&Menu=yes文章来源地址https://www.toymoban.com/news/detail-627371.html

到了这里,关于.Net Framework 4.6.1+版本的Winform程序开启Web服务,支持Http webapi的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • [C#]vs2022安装后C#创建winform没有.net framework4.8

    [C#]vs2022安装后C#创建winform没有.net framework4.8

    问题,我已经在visualstudio安装程序中安装了.net框架4.8的SDK和运行时。 然而,我在visual studio 2022中找不到已安装的框架。 我已经检查了我的VS 2019,它可以很好地定位网络框架4.8,它可以构建我的项目。但VS 2022不能。 我已经重新安装了VS 2022和VS 2019,但VS 2022仍然找不到我的框

    2024年02月07日
    浏览(8)
  • C#桌面程序 winform 集成内置WebApi C# 创建HTTP Web API服务,winform项目创建HTTP WEB服务,不使用IIS业务 C#桌面程序WebApi C#winform集

    C#桌面程序 winform 集成内置WebApi C# 创建HTTP Web API服务,winform项目创建HTTP WEB服务,不使用IIS业务 C#桌面程序WebApi C#winform集

     在维护旧的项目时,有时需要提供APP连接的需求,就要提供HTTP服务,winform项目就要提供HTTP服务,就不用再去写个c# web的IIS相关的业务了,简化项目的复杂度。只需要简单化实例就可以实现提供HTTP服务

    2024年02月08日
    浏览(12)
  • 【Visual Studio 2022创建ASP.NET Web应用程序(.NET Framework)发布并部署到局域网 及“常见权限问题和不列出目录问题解决”】

    【Visual Studio 2022创建ASP.NET Web应用程序(.NET Framework)发布并部署到局域网 及“常见权限问题和不列出目录问题解决”】

    然后给项目命名并选择文件保存位置 用一个空项目进行举例 创建完成如下 点击更多模板选择Web窗体 创建成功如下 .aspx页面编写前端代码,.aspx.cs页面编写后端代码 通过插入表格和拉取控件快速完成 然后给Button按钮设置一个点击事件,双击按钮后会跳到.aspx.cs页面,完善下面

    2024年02月07日
    浏览(25)
  • 开源:Taurus.DTC 微服务分布式事务框架,支持 .Net 和 .Net Core 双系列版本

    开源:Taurus.DTC 微服务分布式事务框架,支持 .Net 和 .Net Core 双系列版本

    在经过1年多的深思,十几年的框架编写技术沉淀下,花了近一个月的时间,终于又为 .Net 及 .Net Core 的微服务系列框架贡献当中的一个重要组件。 https://github.com/cyq1162/Taurus.DTC   由于 CYQ.Data Orm 组件本身支持10多种数据库,因此提供的包,只根据消息队列的需要分拆提供。 默

    2024年02月02日
    浏览(7)
  • VS 2022支持 .NET Framework 4.5的方法

    VS 2022支持 .NET Framework 4.5的方法

    默认Visual Studio 2022 不再支持安装 .NET Framework 4.5 组件   为了避免装回VS 2019,有以下解决办法: 1.nuget 下载 4.5 安装包 下载地址:NuGet Gallery | Microsoft.NETFramework.ReferenceAssemblies.net45 1.0.3 嫌官网下载慢的可以从下方下载 .net4.5 .net4.5.1 .net4.5.2 .net4.6.1  2. 复制文件到系统目录 以 z

    2024年02月07日
    浏览(31)
  • 一个.Net强大的Excel控件,支持WinForm、WPF、Android【强烈推荐】

    一个.Net强大的Excel控件,支持WinForm、WPF、Android【强烈推荐】

    推荐一个强大的电子表单控件,使用简单且功能强大。 这是一个开源的表格控制组件,支持Winform、WPF和Android平台,可以方便的加载、修改和导出Excel文件,支持数据格式、大纲、公式计算、图表、脚本执行等、还支持触摸滑动,可以方便地操作表格。 总的来说是一个可以快

    2024年02月07日
    浏览(8)
  • VS2022 安装 .NET Framework 4.0或.NET Framework 4.5 以及其他版本

    VS2022 安装 .NET Framework 4.0或.NET Framework 4.5 以及其他版本

    VS2019升级到了VS2022之后,安装时已经不提供.NET Framework 4.0和.NET Framework 4.5的目标框架了,打开VS也提示不支持目标框架。 下载.NET Framework框架 官网下载对应版本的sdk:https://dotnet.microsoft.com/zh-cn/download/visual-studio-sdks?cid=getdotnetsdk 点击开发者工具包进行下载; 下载完之后直接双

    2024年02月11日
    浏览(23)
  • Visual Studio 2022 增加对 .NET Framework 4.5 的支持

    Visual Studio 2022 增加对 .NET Framework 4.5 的支持

    VS2022默认最低只支持到 .NET Framework 4.5.2,在 .NET Framework 版本和依赖关系 可以看到 Windows Server 2012 默认安装的是 4.5 的版本,如果老的服务器不方便升级,则需要软件能支持 4.5 的版本 首先,新建 Test1 项目,.NET 版本随便选择 打开 工具 - NuGet 包管理器 - 管理解决方案的 NuGet

    2024年02月05日
    浏览(7)
  • 查看电脑.NET Framework版本和.NET5.0的安装
  • 不同版本的 .NET Framework 下的 csc编译器的版本

    以下是不同版本的 .NET Framework 下的 csc.exe 编译器的版本: .NET Framework 2.0 - 3.5: csc.exe 版本:2.0.xxxxxx .NET Framework 4.x: .NET Framework 4.0: csc.exe 版本:4.0.xxxxxx .NET Framework 4.5 - 4.8: csc.exe 版本:4.0.xxxxxx .NET Framework 4.5.1 以及更新版本(4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8): csc.exe 版本

    2024年02月12日
    浏览(10)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包