几周前,我们将服务器从.NET 4.5更新到4.5.1,并将代码更改为"优化代码"
在nexcoming发布期间,我们开始在日志中收到一条错误的错误消息(并且网站也崩溃了)
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文件的编译方式不同。是的? 建议做什么?