翼度科技»论坛 编程开发 .net 查看内容

记录一次.NET6环境使用Visual Studio 2022 V17.6.2版本的异常

3

主题

3

帖子

9

积分

新手上路

Rank: 1

积分
9
开发环境

C#开发环境Visual Studio 2022 V17.6.2版本。
目标框架:

.NET 6.0
错误内容:

系统是Blazor Server框架的系统页面,在使用Visual Studio 2022 V17.6.2版本编译后,执行出现:
  1. TimeStamp: 2023/6/6 13:35:07
  2. MachineName: Light.Yang
  3. AppDomainName: SajetServerApp
  4. OS: Microsoft Windows 10.0.18363
  5. OSArchitecture: X64
  6. ProcessArchitecture: X64
  7. Framework: .NET 6.0.16
  8. UserName: lukel
  9. VSIDE: Microsoft Visual Studio Community 2022 17.0
  10. Message: Unable to set property 'placeholder' on object of type 'Sajet.WebUI.Components.SelectInput`1[[System.String,System.Private.CoreLib,Version=6.0.0.0, Culture=neutral,PublicKeyToken=7cec85d7dea7798e]]'.The error
  11. was: Unable to cast object of type 'MicrosoftExtensions.Localization.localizedString' to type 'System.Strinq'.
  12. **********************************************
  13. StackTrace: at Microsoft.AspNetCore.Components.Reflection.ComponentProperties.g_SetProperty|3_0(Object target,PropertySetter writer,String parameterName,Object value)
  14. at Microsoft.AspNetCore.Components.Reflection.ComponentProperties.SetProperties(ParameterView& parameters, Obiect target)
  15. at Microsoft.AspNetCore.Components.ParameterView.SetParameterProperties(Object target)
  16. at BootstrapBlazor.Components.ValidateBase`1.SetParametersAsync(ParameterView parameters)
  17. at Microsoft.AspNetCore.Components.Rendering.ComponentState.SupplyCombinedParameters(ParameterView directAndCascadingParameters)
复制代码
问题分析过程:


  • 先使用了Visual Studio 2022 V17.4.0版本编译后可以正常。
  • 经过分析:Visual Studio 2022 V17.4.0还在使用的目标框架为:.NET 6.0,Visual Studio 2022 V17.6.2版本的目标框架为:.NET 7.0
  • 首先怀疑目标框架为:.NET 7.0造成的不兼容的问题,尝试System.Private.CoreLib.dll的NET6.0版本。直接放在系统执行环境中,尝试是否可以正常使用,结果:失败。
  • 再次尝试,安装Visual Studio 2022旧版本,因为在官方网站上下载的Visual Studio 2022都是最新版本。下载地址:下载 Visual Studio Tools - 免费安装 Windows、Mac、Linux (microsoft.com),Visual Studio 2022 分3类版本:社区版、个人版、企业版;大家可以根据自己需求选则下载,此处连接下载的都是最新版本。
  • 在官方网站中查找VS2022的历史版本:Visual Studio 2022 发行历史记录 | Microsoft Learn,以下内容可以选择自己的版本,经过测试:17.2版本支持最新的.NET6.0框架,17.4.1版本以后就支持.NET7.0框架。下载17.2版本中的最新版本:17.2.15版本。

  • 经过测试,Visual Studio 2022 V17.2.15版本,编译后的程序可以正常使用。
  • 通过其他人员安装的不同版本VS2022进行测试结果如下
VS 2022版本支持最新框架测试结果Visual Studio 2022 V17.6.2.NET6.0出现异常Visual Studio 2022 V17.5.2.NET7.0正常Visual Studio 2022 V17.4.0.NET6.0正常Visual Studio 2022 V17.2.15.NET6.0正常总结:


  • 通过测试发现,出现问题应该和VS2022的版本有关,和NET7.0环境无关。希望Visual Studio 2022新版本可以解决此BUG吧!
  • 建议:不要盲目的追求使用最新版本的Visual Studio,特别是生产型企业,这样会导致生产停线,造成的损失就比较大了。
  • 官网网站上针对旧版的引导程序(引导程序安装必须有外部网络),提供了“结束支持日期”,害怕结束支持日期一到,引导程序就无法在线安装(我理解的这个不知对不对!!!)。接着研究一下怎么把历史版本保留下来,以后安装时可以通过本地文件直接安装。

来源:https://www.cnblogs.com/LightYang81/archive/2023/06/07/17463420.html
免责声明:由于采集信息均来自互联网,如果侵犯了您的权益,请联系我们【E-Mail:cb@itdo.tech】 我们会及时删除侵权内容,谢谢合作!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x

举报 回复 使用道具