标题: 记录一次.NET6环境使用Visual Studio 2022 V17.6.2版本的异常 [打印本页] 作者: 一给 时间: 2023-6-7 17:58 标题: 记录一次.NET6环境使用Visual Studio 2022 V17.6.2版本的异常 开发环境
C#开发环境Visual Studio 2022 V17.6.2版本。
目标框架:
.NET 6.0
错误内容:
系统是Blazor Server框架的系统页面,在使用Visual Studio 2022 V17.6.2版本编译后,执行出现:
TimeStamp: 2023/6/6 13:35:07
MachineName: Light.Yang
AppDomainName: SajetServerApp
OS: Microsoft Windows 10.0.18363
OSArchitecture: X64
ProcessArchitecture: X64
Framework: .NET 6.0.16
UserName: lukel
VSIDE: Microsoft Visual Studio Community 2022 17.0
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
was: Unable to cast object of type 'MicrosoftExtensions.Localization.localizedString' to type 'System.Strinq'.
**********************************************
StackTrace: at Microsoft.AspNetCore.Components.Reflection.ComponentProperties.g_SetProperty|3_0(Object target,PropertySetter writer,String parameterName,Object value)
at Microsoft.AspNetCore.Components.Reflection.ComponentProperties.SetProperties(ParameterView& parameters, Obiect target)
at Microsoft.AspNetCore.Components.ParameterView.SetParameterProperties(Object target)
at BootstrapBlazor.Components.ValidateBase`1.SetParametersAsync(ParameterView parameters)
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
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吧!