When I assign an html file to a WebBrowser's Url property, I get this Script err:
So, in an effort to determine what is causing the mayhem, I changed the extension of the file from .html to .txt and tried this code, starting from a spot just before what was flagged as bad:
int dangerZone = 95217560;
string path = @"C:\misc\mapcode_20160720_022208.txt";
string readText = File.ReadAllText(path);
string stuffNearAndPastTheProblem = readText.Substring(dangerZone);
MessageBox.Show(stuffNearAndPastTheProblem);
...but, instead of being enlightened with whatever html is malformed or otherwise problematic, I get a crash that tells me:
System.ArgumentOutOfRangeException was unhandled HResult=-2146233086 Message=startIndex cannot be larger than length of string.
How can there be a problem at character 95217563 when there are not even 95217560 characters in the file?
UPDATE
Okay, I tried this to check the length:
var chars = readText.ToCharArray();
MessageBox.Show(chars.Length.ToString());
...and it tells me 24131.
So the char position from the err msg is, indeed, the epitome of bogusness.
UPDATE 2
So I changed the "dangerZone" value to 2100, and the MessageBox displayed is bigger than King Kong on steroids. So obviously there are a lot more than 24131 chars...
Maybe what's happening is that these lines in the .html/.txt file:
sb.Append("<script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js\"></script> ");
sb.Append("<script src=\"http://maps.google.com/maps/api/js?sensor=false\"></script> ");
sb.Append("<script src=\"gomap.js\"></script> ");
sb.Append("<!--[if IE]>");
sb.Append("<script src=\"http://html5shiv.googlecode.com/svn/trunk/html5.js\"></script>");
sb.Append("<![endif]-->");
...are including those referenced .js files in the err msg's character locating calculations. IOW, it may be inserting those referenced files "inline" like so:
part of my file
jquery.min.js
google maps api js
gomap.js
html5.js
...and then back to the rest of my file
...and then basing the problematic char location on all of that combined html and js, whereas only a relatively small subset is actually contained in the .text file.
If my hunch about the frankensteinization of the script's "working set" is correct, then yes, the "bad char" location provided in the Script err msg is pretty much useless (in my case, anyway).