首先,这很可能是我的新手错误,我对.net和c#很新。
我在最新项目中使用CMS系统Umbraco,最近的更新意味着系统已开始使用System.Globalization.CultureInfo类来处理本地化。这导致CMS后台中出现多个“未找到文化”错误,导致其无法使用。这是来自其中一个的堆栈跟踪:
Server Error in '/' Application.
Culture is not supported.
Parameter name: name
.-no is an invalid culture identifier.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Globalization.CultureNotFoundException: Culture is not supported.
Parameter name: name
.-no is an invalid culture identifier.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[CultureNotFoundException: Culture is not supported.
Parameter name: name
.-no is an invalid culture identifier.]
System.Globalization.CultureInfo.GetCultureInfo(String name) +12488971
Umbraco.Core.Services.LocalizedTextServiceFileSources.<.ctor>b__0() +573
System.Lazy`1.CreateValue() +180
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +26
System.Lazy`1.get_Value() +12446617
Umbraco.Core.Services.LocalizedTextServiceFileSources.TryConvert2LetterCultureTo4Letter(String twoLetterCulture) +61
Umbraco.Core.Services.LocalizedTextService.ConvertToSupportedCultureWithRegionCode(CultureInfo currentCulture) +110
Umbraco.Core.Services.LocalizedTextService.GetAllStoredValues(CultureInfo culture) +72
Umbraco.Web.Editors.BackOfficeController.LocalizedText(String culture) +123
lambda_method(Closure , ControllerBase , Object[] ) +77
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +157
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +22
System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +50
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +225
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +225
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +225
System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +26
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9765121
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
我仍然不完全确定。-no来自哪里,但经过一些研究后我尝试运行以下代码并插入断点:
var locale = CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures);
这返回null,似乎没有在任何地方抛出异常。我猜这可能是错误的原因,从堆栈跟踪判断。这可能是我本地设置的问题吗?我正在运行Windows 10,主要是在虚拟化环境中,但它也可以通过OSX Bootcamp本地运行,问题似乎仍然存在。我也尝试使用Powershell输出已安装的文化列表,这样可以正常工作。
如果有帮助,我使用IISExpress作为Web服务器,数据库在SQL Server 2016 Express下运行。
提前致谢!如果我能提供任何额外的信息来帮助我,请告诉我。
答案 0 :(得分:0)
利用Umbraco是开源的这一事实。
从您提供的堆栈跟踪和异常详细信息判断,问题是由以下行引起的:
显然将无效值.-no
传递给GetCultureInfo
方法。如果你在源代码中看起来有点像,那么这个值似乎来自XML文件名或XML文件内容。
我无法为您的问题提供完整的解决方案,但是有些事情可以尝试找出它的根本原因:
1)清理部署文件夹
彻底清洁&amp;重建周期
2)检查本地化XML文件以检查它们是否包含有效的文化
如果您手动编辑了文件,请确保没有拼写错误。
3)比较&#34; fresh&#34;的文件夹安装和您的非工作解决方案文件夹
检查更新是否还没有留下以前版本的某些XML文件;