我已经在.net 8中发布了一个c# web.API到一个azure web.API资源。
当我打开到SQL的连接时,我遇到了以下错误:
System.Globalization.CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'name')
en-us is an invalid culture identifier.
at System.Globalization.CultureInfo.GetCultureInfo(String name)
at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry, SqlConnectionOverrides overrides)
at Microsoft.Data.SqlClient.SqlConnection.InternalOpenAsync(CancellationToken cancellationToken)
字符串
我在项目属性中设置了以下内容:
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>disable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>false</InvariantGlobalization>
</PropertyGroup>
型
这在当地有效。
当我发布到Azure并查看Azure上的文件时,我在runtimeconfig.json中注意到:
{“runtimeOptions”:{“tfm”:“net8.0”,“frameworks”:[ {“name”:“Microsoft.NETCore.App”,“version”:“8.0.0”},{“name”:“Microsoft.AspNetCore.App”,“version”:“8.0.0”} ],“属性”:{“System.GC.Server”:true,“System.Globalization.Invariant”:true,“System.Globalization.PredefinedCulturesOnly”:true,“System.Reflection.Metadata.MetadataUpdater.IsSupported”:false,“System. Reflection.Serialization. EnableUnsafeBinarySerialization”:false } } }
我在.net 6示例上运行时没有这个问题。有人能帮助我并解释我应该如何解决我的问题吗?
非常感谢提前。
罗布
1条答案
按热度按时间xkftehaa1#
根据文档,.NET 8现在默认为
globalization invariant mode
,如果你不指定为detailed here.为了启用对区域性的访问,您需要更新以下设置之一:
runtimeconfig.json
个字符串
Project file
个型
More documentation here regarding Globalization configuration.的