简体   繁体   English

Microsoft AJAX脚本的JavaScript运行时错误

[英]JavaScript runtime error for Microsoft AJAX scripts

I have an ASP.NET web forms project in VS.NET 2012 that has been running great for weeks. 我在VS.NET 2012中有一个ASP.NET Web表单项目,运行了几个星期。 All of the sudden out of nowhere I'm getting the following everytime I begin to debug the project: 突然,我每次开始调试项目时都会得到以下提示:

Unhandled exception at line 1, column 12302 in http:// localhost :1449/bundles/MsAjaxJs?v=_Onj24X0Yu7cK2nh78YBmVwMlQTGcakS5HZSOI_a6SM1 第1行第http:// localhost:1449 / bundles / MsAjaxJs?v = _Onj24X0Yu7cK2nh78YBmVwMlQTGcakS5HZSOI_a6SM1中的未处理异常

0x800a139e - JavaScript runtime error: Sys.InvalidOperationException: The script 'Timer.js' has been referenced multiple times. 0x800a139e-JavaScript运行时错误:Sys.InvalidOperationException:脚本“ Timer.js”已被多次引用。 If referencing Microsoft AJAX scripts explicitly, set the MicrosoftAjaxMode property of the ScriptManager to Explicit. 如果显式引用Microsoft AJAX脚本,请将ScriptManager的MicrosoftAjaxMode属性设置为Explicit。

(note: added spaces in error message to word 'localhost' because these URLs are not formed well for posting; link is irrelevant anyway) (注意:错误消息中的空格添加到单词“ localhost”,因为这些URL的格式不适合发布;无论如何,链接都不相关)

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. 我对此进行了一些搜索,并提出了可以使其工作的所有方法。

In the auto-generated BundleConfig.cs , this file is only listed 1x: 在自动生成的BundleConfig.cs ,此文件仅列出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-*"));
}

In the web.config there is no duplicate or listing otherwise for the timer. 在web.config中,没有重复或列出计时器。 I did a search on the project and this was the only place it was listed. 我在该项目上进行了搜索,这是它被列出的唯一地方。

I also made sure all of the NuGet packages where up to date. 我还确保所有NuGet软件包都是最新的。 Anyone understand or know what has caused this error, and how can I fix it? 任何人都了解或知道导致此错误的原因是什么,我该如何解决?

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. 我得相信我下载的是单独注册这些文件的NuGet包更新之一,并在同一时间必须有新的逻辑。 I say this because this issue started out of nowhere. 我之所以这样说,是因为这个问题无处不在。

The solution was simply to comment out or remove the offending scripts that were being registered more than 1x in the BundleConfig.cs file. 解决方案只是注释掉或删除BundleConfig.cs文件中已注册超过1x的有害脚本。 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"));

The following (2) scripts were the culprit: 罪魁祸首是以下(2)个脚本:

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

After removing them the error went away, the functionality within those scripts still works (I use Ajax timers), and the error went away. 删除它们后,错误消失了,这些脚本中的功能仍然有效(我使用Ajax计时器),并且错误消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Microsoft JScript运行时错误:AjaxControlToolkit需要ASP.NET Ajax 4.0脚本 - Microsoft JScript runtime error: AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts SliderExtender导致0x800a139e-Microsoft JScript运行时错误:AjaxControlToolkit是否需要ASP.NET Ajax 4.0脚本? - SliderExtender causing 0x800a139e - Microsoft JScript runtime error: AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts? Javascript运行时错误:函数预期的ajax调用 - Javascript runtime error:function expected ajax call 更新面板抛出 javascript 错误:“Microsoft JScript 运行时错误:找不到成员” - Update Panel throws javascript error: “Microsoft JScript runtime error: Member not found” JavaScript运行时错误:“ $”未定义 - JavaScript runtime error: '$' is undefined JavaScript 运行时错误:InvalidStateError - JavaScript runtime error: InvalidStateError IE中的JavaScript运行时错误 - JavaScript runtime error in IE MVC Jquery Ajax请求错误0x800a138f-JavaScript运行时错误:预期对象 - MVC Jquery Ajax Request error 0x800a138f - JavaScript runtime error: Object expected BHO插件(Microsoft JScript运行时错误) - BHO Plugin (Microsoft JScript runtime error) jQuery“Microsoft JScript运行时错误:对象预期” - jQuery “Microsoft JScript runtime error: Object expected”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM