【问题标题】:Weird ASP.NET AJAX Bug / 32-bit to 64-bit奇怪的 ASP.NET AJAX 错误 / 32 位到 64 位
【发布时间】:2009-01-08 02:42:19
【问题描述】:

自从升级到 Windows 2008 64 位后,我的网站收到了一个奇怪的错误。我的大部分应用程序池都在 64 位模式下运行(除了一个,都用于旧版 ASP.NET 1.1 应用程序)。在运行 64 位的网站上,我收到了来自 ASP.NET AJAX 的错误。

Exception information:
   Exception type: System.NotSupportedException
   Exception message: Assembly "AjaxControlToolkit, Version=3.0.20820.16598, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" does not contain a script with hash code "e2e86ef9".

Request information:
   Request URL: http://site.com/page.aspx?_TSM_HiddenField_=ctl00_ctl00_elScripto_HiddenField&_TSM_CombinedScripts_=%3B%3BAjaxControlToolkit%2C+Version%3D3.0.20820.16598%2C+Culture%3Dneutral%2C+PublicKeyToken%3D28f01b0e84b6d53e%3Afr-FR%3A707835dd-fa4b-41d1-89e7-6df5d518ffb5%3Ae2e86ef9%3A9ea3f0e2%3A9e8e87e9%3A1df13a87%3Ad7738de7

Thread information:
   Thread ID: 21
   Thread account name: NT AUTHORITY\NETWORK SERVICE
   Is impersonating: False
   Stack trace:    at AjaxControlToolkit.ToolkitScriptManager.DeserializeScriptEntries(String serializedScriptEntries, Boolean loaded) in c:\AjaxControlToolkit_Admin\Release\AjaxControlToolkit\ToolkitScriptManager\ToolkitScriptManager.cs:line 534
  at AjaxControlToolkit.ToolkitScriptManager.OutputCombinedScriptFile(HttpContext context) in c:\AjaxControlToolkit_Admin\Release\AjaxControlToolkit\ToolkitScriptManager\ToolkitScriptManager.cs:line 264
  at AjaxControlToolkit.ToolkitScriptManager.OnInit(EventArgs e) in c:\AjaxControlToolkit_Admin\Release\AjaxControlToolkit\ToolkitScriptManager\ToolkitScriptManager.cs:line 198
  at System.Web.UI.Control.InitRecursive(Control namingContainer)
  at System.Web.UI.Control.InitRecursive(Control namingContainer)
  at System.Web.UI.Control.InitRecursive(Control namingContainer)
  at System.Web.UI.Control.InitRecursive(Control namingContainer)
  at System.Web.UI.Control.InitRecursive(Control namingContainer)
  at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

该错误似乎是 CodePlex 中的一个已知问题,但这对我没有多大帮助。这是一个解释问题的链接: http://dotnetdebug.net/2008/05/25/ajaxcontroltoolkit-toolkitscriptmanager-stringgethashcode-and-mixing-32bit-and-64bit-machinesprocesses/

我没有使用负载平衡,我想知道为什么我的应用程序会在 32 位和 64 位模式之间切换。

是否必须为 64 位架构或类似的架构编译 DLL?是否有任何我应该注意的奇怪问题可能会导致我遇到此问题?

【问题讨论】:

    标签: asp.net-ajax 64-bit


    【解决方案1】:

    看起来 String.GetHashCode() 结果会根据 dll 编译的指令集而变化。我无法解释为什么当您的 .NET 2.0+ 应用程序池都是 64 位时会在框架内发生这种情况,但是如果您愿意从 codeplex 获取最新的源代码并在工具包脚本管理器。

    我不知道为什么没有根据可用的 cmets 提交官方修复 - 可能是因为所有解决方案都和我的一样丑?

    我已尝试使用其中一个 cmets 中描述的 SHA1 哈希例程来修复它——所以首先我在 ToolkitScriptManager 类中创建了一个 SHA1Managed 提供程序的静态实例,如下所示:

    public class ToolkitScriptManager : ScriptManager
    {
        private static System.Security.Cryptography.SHA1Managed s = new System.Security.Cryptography.SHA1Managed();
    

    ...

    然后有两个地方使用了我注释掉和替换的字符串哈希码——一次是在 SerializeScriptEntries 函数中:

    //serializedScriptEntries.Append(scriptEntry.Name.GetHashCode().ToString("x", CultureInfo.InvariantCulture));
    serializedScriptEntries.Append(Convert.ToBase64String(s.ComputeHash(System.Text.Encoding.UTF8.GetBytes(scriptEntry.Name))));
    

    然后在 DeserializeScriptEntries 函数中一次:

    //string hashCode = resourceName.GetHashCode().ToString("x", CultureInfo.InvariantCulture);
    string hashCode = Convert.ToBase64String(s.ComputeHash(System.Text.Encoding.UTF8.GetBytes(resourceName)));
    

    也许一个更简单的方法可以让我们只访问 64 位 GetHashCode 方法来序列化这个字符串,以便我们在 32 位和 64 位调用中获得相同的结果...

    【讨论】:

    • 看起来很有希望。我不想运行我自己的工具包管理器实例,但很乐意为这个解决方案投票,这样它就会被纳入主要产品。
    猜你喜欢
    • 2012-08-28
    • 1970-01-01
    • 2018-12-29
    • 1970-01-01
    • 2016-07-13
    • 1970-01-01
    • 2012-10-26
    • 2012-06-26
    • 1970-01-01
    相关资源
    最近更新 更多