几周前,我们将服务器从 .NET 4.5 更新到 4.5.1,并将代码更改为作为“优化代码”运行
在即将发布的版本中,我们开始在日志中收到奇怪的错误消息(并且网站刚刚崩溃)
System.ArgumentException: An item with the same key has already been added.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark)
at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark)
at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture, Boolean wrapUnmanagedMemStream)
at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture)
at System.Web.Compilation.BaseResXResourceProvider.GetObject(String resourceKey, CultureInfo culture)
at System.Web.Compilation.ResourceExpressionBuilder.GetResourceObject(IResourceProvider resourceProvider, String resourceKey, CultureInfo culture, Type objType, String propName)
at System.Web.UI.TemplateControl.GetLocalResourceObject(String resourceKey)
at ASP.masterpages_master_master.__BuildControlbritishLink() in c:\\Workspace\\MyApp\\Admin\\MasterPages\\Master.master:line 39
at ASP.masterpages_master_master.__BuildControlheaderPanel() in c:\\Workspace\\MyApp\\Admin\\MasterPages\\Master.master:line 35
at ASP.masterpages_master_master.__BuildControlform1() in c:\\Workspace\\MyApp\\Admin\\MasterPages\\Master.master:line 27
at ASP.masterpages_master_master.__BuildControlTree(masterpages_master_master __ctrl) in c:\\Workspace\\MyApp\\Admin\\MasterPages\\Master.master:line 1
at ASP.masterpages_master_master.FrameworkInitialize() in c:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\Temporary ASP.NET Files\\admin\\dbad5a18\\4cede7d0\\App_Web_vk3fiqpm.0.cs:line 0
at System.Web.UI.UserControl.InitializeAsUserControlInternal()
at System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection)
at System.Web.UI.MasterPage.get_Master()
at System.Web.UI.MasterPage.ApplyMasterRecursive(MasterPage master, IList appliedMasterFilePaths)
at System.Web.UI.Page.ApplyMasterPage()
at System.Web.UI.Page.PerformPreInit()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
我们使用 .resx 文件进行翻译,首先想到的是我们在 resex 文件中存在重复的密钥,但事实并非如此。经过几个小时的调查,我们无法清楚地了解发生了什么。因此,我们开始回收应用程序池,这暂时解决了问题。
我们从未在我们的开发环境中看到过这个问题(直到几天前),我们所做的就是删除所有临时文件
Get-ChildItem “C:\Windows\Microsoft.NET\Framework*\v*\Temporary ASP.NET Files” -Recurse | Remove-Item -Recurse
(因为它涉及的是 .resx 文件正在使用 JIT 编译器进行编译并保存在临时文件中?这是正确的吗?)
这修复了我们开发环境中的错误,因此我们也在我们的一台生产服务器上进行了尝试,该服务器修复了一小段时间的错误,但随后又回来了。我们不明白当我们在两个环境上拥有相同的设置和版本时,这如何在我们的开发服务器上工作,但在生产服务器上不起作用(我们已经进行了比较)
有人遇到过类似的问题吗?如果有,你做了什么?
我们现在必须监视我们的服务器并查看,因为错误时不时会出现,它是随机的,并且它不会为我们提供更多信息,正如我在此处提供的那样。我们已经开启了更多的日志记录,但这并没有给我们更多的支持。
现在要清除的错误是随机的,我们不知道它何时出现或为什么出现,我们没有更多的内容可以继续。
当“优化代码”打开时,.resex 文件的编译方式是否会有所不同?
建议做什么?