升级 Net 7 随手笔记 (注意事项以及解决方案) - 持续更新

  1. 条件编译 #if NET6_0 改为 #if NET7_0 或者 #if NET6_0_OR_GREATER
#if NET6_0_OR_GREATER
using BootstrapBlazor.Components;
#endif
  1. 项目目标支持6和7改为<TargetFramework>net6.0;net7.0</TargetFrameworks>,只需要7直接改为<TargetFramework>net7.0</TargetFramework>

    多目标引用库参考

	<ItemGroup Condition="'$(TargetFramework)' != 'net7.0'">
		<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="6.0.0" />
	</ItemGroup>

	<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
		<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="7.0.0" />
	</ItemGroup> 
	<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
	  <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.10" />
	  <PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
	</ItemGroup>

	<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
		<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0" />
		<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0" />
	</ItemGroup> 
  1. Maui工程或者库参考目标方案
<TargetFrameworks>netstandard2.0;netstandard2.1;net461;net6.0;net6.0-windows10.0.19041;net6.0-ios;net6.0-maccatalyst;net6.0-android;net7.0;net7.0-windows10.0.19041;net7.0-ios;net7.0-maccatalyst;net7.0-android</TargetFrameworks>
  1. 多目标 net461;net7.0 提示冲突 System.Drawing 存在于 4.0 和 7.0
    <ItemGroup Condition=" '$(TargetFramework)' == 'net7.0' ">
        <PackageReference Include="System.Drawing.Common" Version="7.0.0" />
        <PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0" />
    </ItemGroup> 
  1. BrotliCompressionProviderOptions 提示 (CompressionLevel)4 不正确
            builder.Services.Configure<BrotliCompressionProviderOptions>(options =>
            {
                //options.Level = (CompressionLevel)4;
                options.Level = CompressionLevel.Optimal; //改为这个
            });
  1. 库生成提示 ‘xxx.dll’ does not contain an entry point. 项目文件 PropertyGroup 内加入 <OpenApiGenerateDocuments>false</OpenApiGenerateDocuments>

  2. 提示 证书链是由不受信任的颁发机构颁发的 , 链接串后加入 ;Encrypt=False

  3. 有编辑过 xxx.runtimeconfig.json 文件的同学注意了: 升级了net7,这个文件也要相应的更新. 例如本人就加过这句

"System.Drawing.EnableUnixSupport": true

并且生成 release 特定跳过了复制这个文件 xxx.runtimeconfig.json 倒置发布到 centos后服务无法启动,一直提示

  Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. 
  The located assembly's manifest definition does not match the assembly reference. (0x80131040)
  File name: 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

排查了半天才想起这个文件. 新版默认文件内容为

{
  "runtimeOptions": {
    "tfm": "net7.0",
    "frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "7.0.0"
      },
      {
        "name": "Microsoft.AspNetCore.App",
        "version": "7.0.0"
      }
    ],
    "configProperties": {
      "System.GC.Server": true,
      "System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
      "System.Reflection.NullabilityInfoContext.IsSupported": true,
      "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false,
      "System.Drawing.EnableUnixSupport": true //这句是我项目另外加的
    }
  }
}
  1. 库升级 .Net 7.0 后生成提示 Assembly “xxx.dll” does not contain an entrypoint 临时解决办法
    在工程项目文件.csproj 添加这行
<PropertyGroup>
  ...
  <OpenApiGenerateDocuments>false</OpenApiGenerateDocuments>
  ...
</PropertyGroup>

就可以跳过 GenerateOpenApiDocuments 继续生成了

  1. 升级vs或者装了.Net 7.0后, 工程框架用 net6 的 dotnet watch 出错 'Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly ‘System.Runtime, Version=7.0.0.0’

工程框架

<TargetFramework>net6.0</TargetFramework>

错误

dotnet watch 🚀 Started
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

File name: 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at System.Reflection.RuntimeAssembly.GetType(QCallAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive, ObjectHandleOnStack assemblyLoadContext)
   at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
   at System.Reflection.Assembly.GetType(String name, Boolean throwOnError)
   at System.StartupHookProvider.CallStartupHook(StartupHookNameOrPath startupHook)
   at System.StartupHookProvider.ProcessStartupHooks()

临时解决方案: 工程目录下建立 global.json 文件指定编译框架

{
  "sdk": {
    "version": "6.0.403"
  }
}
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Net-SNMP是一个用于实现SNMP(Simple Network Management Protocol,简单网络管理协议)的工具包。学习Net-SNMP主要包括以下几个方面: 1. 编译和安装Net-SNMP:首先需要下载和解压Net-SNMP的源代码,然后通过命令行进行编译和安装。 2. 编写MIB文件:MIB(Management Information Base,管理信息库)文件用于定义被SNMP管理的对象。你可以使用文本编辑器编写MIB文件,其中包含了对象的标识符和相关信息。 3. 转换MIB文件:将MIB文件转换成.c和.h文件,这样可以在SNMP代理中使用。可以使用工具来进行这个转换过程。 4. Agent代理工程:Agent代理是一个运行在网络设备上的软件模块,它负责收集和提供设备的管理信息给SNMP管理系统。学习Net-SNMP还需要了解如何配置和运行Agent代理工程。 5. Trap机制:Trap是SNMP的一种机制,用于报告特殊事件的发生。学习Net-SNMP时需要了解如何配置Trap机制,以便及时获得网络资源的实时监控。 总之,学习Net-SNMP主要包括编译和安装Net-SNMP,编写和转换MIB文件,配置和运行Agent代理工程,以及理解Trap机制等方面。这些知识可以帮助你实现有效的网络管理软件。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [SNMP网管学习笔记](https://download.csdn.net/download/qiek/6674485)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [net-snmp学习笔记<一> — 介绍](https://blog.csdn.net/prochsh/article/details/49888141)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Densen2014

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值