• Home
  • About
  • Resume

Solution for IE10 error: SCRIPT5022: Sys.ArgumentOutOfRangeException: Value must be an integer

By , 05/01/2013 2:05 PM

If you’re testing your ASP.NET project in Internet Explorer 10, you may encounter following error:

SCRIPT5022: Sys.ArgumentOutOfRangeException: Value must be an integer.
Parameter name: (x or y)
Actual value was (some floating point value)
ScriptResource.axd, line … character …

Often it come up when you use some 3rd party libraries, Telerik or Infragistics (in my case it happened in WebDataMenu control).

Here why it happens. Actual error happens in Sys.UI.Point class. In its constructor it expects 2 parameters – x and y. If you trace the callstack you will see that these values are provided to the class by a preceding call to browser’s intrinsic function getBoundingClientRect(). In previous versions of IE it returned Integer values. But in IE10 values are floating point.

Now if you’re using older version of .NET Framework (e.g. 3.5 or below) you’ve got a problem. Sys.UI.Point class expects parameters to be strictly Integer. Since IE10 provides fractionals – error shown above is thrown.

There could be other incompatibilities, so the only real, non-hacky solution, well – upgrade your project to a more recent version of .NET framework (4.5 at the time of this post).

If upgrading is not possible and you’re willing to accept the risk of a hack – include following function into your page:

Sys.UI.Point = function Sys$UI$Point(x, y) {

    x = Math.round(x);
    y = Math.round(y);

    var e = Function._validateParams(arguments, [
        {name: "x", type: Number, integer: true},
        {name: "y", type: Number, integer: true}
    ]);
    if (e) throw e;
    this.x = x;
    this.y = y;
}

This function will replace original one and the only addition is rounding of incoming parameters.


UPDATE 6/6/2013: After playing with this for a while I realized one interesting thing – the above error happens only if my project is in debug mode <compilation debug="true"> is set. As soon as I change it to <compilation debug="false"> the error goes away. You may still have to update browser definition file to avoid ‘_doPostBack’ is undefined JavaScript error, but that’s another story.

12 Responses to “Solution for IE10 error: SCRIPT5022: Sys.ArgumentOutOfRangeException: Value must be an integer”

  1. Tim says:

    Wow! Thank you. This was seriously helpful to me. Sadly, I’m trapped in .NET 3.5.

  2. Jgd says:

    Thanks man, you really helped me out here!!

  3. Paresh says:

    in which page we need to inlcude.

  4. Yuriy says:

    @Paresh ASPX page that throws error is the best bet

  5. Kat says:

    I am running it to this problem, and using 3.5 (cant upgrade) that function doesnt seem to get triggered on my aspx page when i mouse over my WebDataMenu control. any ideas?

  6. Yuriy says:

    @Kat, are you still experiencing the problem when your project is running with compilation debug=”false” In my case it helped the issue even without the Infragistics hack (which I still recommend to avoid) ?

  7. Max says:

    Works like a charm. Huge time saver. Thanks!

  8. Carsten says:

    Hi Yuriy

    When I include it on my default.aspx I get a new javascript error saying: Sys is not defined.
    ??

  9. Yuriy says:

    @Carsten When in your code do u insert the above fix? Sys is defined on that page otherwise you wouldn’t get original “Sys.ArgumentOutOfRangeException” error.

  10. Carsten says:

    @yuriy I tried inserting all over (in head, in body, first and last) with no luck.
    Ended up editing the original MicrosoftAjax.js file to do the rounding, that fixed it. 🙂
    My system is a rather old complex asp.net one using lots of clever including and on-the-fly loading of components, coded before I joined.
    but thanx anyways you code guided me to the correct change in the microsoftajax.js file.

  11. Tung Tran says:

    Add this after scriptmanager

  12. kirti says:

    thanks a lot Yuriy
    you made my day

Leave a Reply

Panorama Theme by Themocracy