jamietre / CsQuery

CsQuery is a complete CSS selector engine, HTML parser, and jQuery port for C# and .NET 4.
Other
1.16k stars 250 forks source link

Add to ChildNodeList .NET Framework 4.5 Dictionary Resize 'Index was outside the bounds of the array' exception #140

Closed gorban closed 10 years ago

gorban commented 10 years ago

I believe this issue is similar to issue #63 The problem started occurring when we installed .NET 4.5 on a server. Trouble data caused the issue again when copied to a .NET 4.0 dev machine which was then upgraded to .NET 4.5 We have had a few cases of trouble data under normal use scenarios which had always worked before the .NET upgrade.

Error Message:::
Index was outside the bounds of the array.

Stack Trace:::
at System.Collections.Generic.Dictionary2.Resize(Int32 newSize, Boolean forceNewHashCodes) at CsQuery.Implementation.RangeSortedDictionary1.Add(String key, TValue value) at CsQuery.Implementation.DomDocument.AddToIndex(String key, IDomIndexedNode element) at CsQuery.Implementation.DomDocument.AddToIndex(IDomIndexedNode element) at CsQuery.Implementation.ChildNodeList.AddParent(IDomObject element, Int32 index) at CsQuery.Implementation.ChildNodeList.Add(IDomObject item) at CsQuery.Implementation.DomContainer1.AppendChild(IDomObject item) at CsQuery.CQ.Wrap(IEnumerable1 wrapper, Boolean keepSiblingsTogether) at CsQuery.CQ.Wrap(IEnumerable`1 wrapper) at CsQuery.CQ.Wrap(String wrappingSelector) at [proprietary code here]

jamietre commented 10 years ago

What version are you using? This was a bug but it was fixed a long time ago - if this is happening to you in 1.3.4 can you try the prerelease version (1.3.5-beta5) which is on nuget (just select "include prereleases")

gorban commented 10 years ago

The problem was resolved when I grabbed the latest 1.3.5 beta 5.

jamietre commented 10 years ago

Good - i really need to make that a release, i had forgotten this bug was still in the current release version!

gorban commented 10 years ago

I was using what appeared to be a version from a commit labeled 1.3.4 (but marked as 1.3.3 in AssemblyInfo.cs) from Github and not the 1.3.4 release from Nuget. Also, I believe #63 was fixed before this commit and instead we had a deployment issue where the newer dll did not copy and replace the older version, so you should not need to make a separate release version. Apologies.

jamietre commented 10 years ago

Well I remember there was at least one release where the assembly version number didn't match the nuget release. so this confusion might be my fault still. In any event there are plenty of other reasons for me to get the current code out, not the least of which that it's been six months.