对Microsoft AJAX脚本的JavaScript运行时错误 [英] JavaScript runtime error for Microsoft AJAX scripts

查看:1140
本文介绍了对Microsoft AJAX脚本的JavaScript运行时错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS.NET 2012的ASP.NET Web窗体项目,该项目已经运行的伟大的几个星期。突然之间冒出我得到以下每次我开始调试项目:

I have an ASP.NET web forms project in VS.NET 2012 that has been running great for weeks. All of the sudden out of nowhere I'm getting the following everytime I begin to debug the project:

未处理的异常在行1,列12302在
  HTTP://本地主机:1449 /包/ MsAjaxJs V = _Onj24X0Yu7cK2nh78YBmVwMlQTGcakS5HZSOI_a6SM1

Unhandled exception at line 1, column 12302 in http:// localhost :1449/bundles/MsAjaxJs?v=_Onj24X0Yu7cK2nh78YBmVwMlQTGcakS5HZSOI_a6SM1

0x800a139e - JavaScript的运行时错误:Sys.InvalidOperationException:
  该脚本Timer.js已经被多次引用。如果
  引用微软AJAX脚本明确,设置
  使用ScriptManager的MicrosoftAjaxMode属性来显式。

0x800a139e - JavaScript runtime error: Sys.InvalidOperationException: The script 'Timer.js' has been referenced multiple times. If referencing Microsoft AJAX scripts explicitly, set the MicrosoftAjaxMode property of the ScriptManager to Explicit.

(注:加空格错误消息,单词本地主机,因为这些URL都没有形成很好张贴,链接反正无关)

(note: added spaces in error message to word 'localhost' because these URLs are not formed well for posting; link is irrelevant anyway)

这是奇怪的,因为它刚开始出现无章可循。我做了这方面的一些搜索和任何可能使其工作上来。

This is odd because it just began to occur out of nowhere. I did some searching on this and came up with anything that would make it work.

在自动生成的 BundleConfig.cs ,该文件仅列1X:

In the auto-generated BundleConfig.cs, this file is only listed 1x:

public static void RegisterBundles(BundleCollection bundles)
{
    bundles.Add(new ScriptBundle("~/bundles/WebFormsJs").Include(
          "~/Scripts/WebForms/WebForms.js",
          "~/Scripts/WebForms/WebUIValidation.js",
          "~/Scripts/WebForms/MenuStandards.js",
          "~/Scripts/WebForms/Focus.js",
          "~/Scripts/WebForms/GridView.js",
          "~/Scripts/WebForms/DetailsView.js",
          "~/Scripts/WebForms/TreeView.js",
          "~/Scripts/WebForms/WebParts.js"));

    bundles.Add(new ScriptBundle("~/bundles/MsAjaxJs").Include(
        "~/Scripts/WebForms/MsAjax/MicrosoftAjax.js",
        "~/Scripts/WebForms/MsAjax/MicrosoftAjaxApplicationServices.js",
        "~/Scripts/WebForms/MsAjax/MicrosoftAjaxTimer.js",
        "~/Scripts/WebForms/MsAjax/MicrosoftAjaxWebForms.js"));

    // Use the Development version of Modernizr to develop with and learn from. Then, when you’re
    // ready for production, use the build tool at http://modernizr.com to pick only the tests you need
    bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
        "~/Scripts/modernizr-*"));
}

在web.config中有没有重复或定时器,否则上市。我做了该项目的搜索,这是其上市的唯一地方。

In the web.config there is no duplicate or listing otherwise for the timer. I did a search on the project and this was the only place it was listed.

我也确信所有的的NuGet 的包,其中最新的。任何人都明白,知道是什么原因造成这个错误,我怎么能解决这个问题?

I also made sure all of the NuGet packages where up to date. Anyone understand or know what has caused this error, and how can I fix it?

推荐答案

解决了这个问题。我得相信我下载了注册这些文件的的的NuGet包更新的一个单独的,并在同一时间必须有新的逻辑。我这样说是因为这个问题开始冒出。

Solved this issue. I have got to believe one of the NuGet package updates I downloaded was registering these files separately, and at the same time must have been new logic. I say this because this issue started out of nowhere.

解决方案是简单地注释掉或删除,正在在 BundleConfig.cs 文件中注册超过1倍以上违规脚本。下面是脚本注册的修改部分:

The solution was simply to comment out or remove the offending scripts that were being registered more than 1x in the BundleConfig.cs file. Here is the modified section of script registration:

bundles.Add(new ScriptBundle("~/bundles/MsAjaxJs").Include(
         "~/Scripts/WebForms/MsAjax/MicrosoftAjax.js",
         "~/Scripts/WebForms/MsAjax/MicrosoftAjaxApplicationServices.js"));

以下(2)脚本是罪魁祸首:

The following (2) scripts were the culprit:

"~/Scripts/WebForms/MsAjax/MicrosoftAjaxTimer.js",
"~/Scripts/WebForms/MsAjax/MicrosoftAjaxWebForms.js"

删除这些错误后就走了,这些脚本中的功能的还是的工作(我使用Ajax定时器),错误就走开了。

After removing them the error went away, the functionality within those scripts still works (I use Ajax timers), and the error went away.

这篇关于对Microsoft AJAX脚本的JavaScript运行时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆