C# – VS2008 MySQL Connector/NET AccessViolationException


I've been struggling for weeks with relentless errors thrown either by VS2008 or MySQL Connector/NET.

These errors appear sort of randomly while messing with Visual Studio's Dataset Designer and, as soon as it starts, it won't stop; It even prevents from saving the XSD file. A pop-up shows:

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

(it turns out to be an AccessViolationException, apparently)

That being said, it doesn't seem to be applicable to the infamous remoting bug, since I'm running .NET 3.5 (and cannot install the fix). I've done a fair amount of research on the net and it pretty much always comes down to this issue.

Furthermore, sometimes, one of the following solution will fix the problem temporarily (applied when the previous fails):

  • Restarting VS2008;
  • Cleaning VS solution;
  • Cleaning SVN working copy;
  • Re-Checkout SVN;
  • Reinstalling MySQL Connector/NET (tried 5.2.6 and 6.0.4);
  • Reinstalling VS2008.

(I'm also using AnhkSVN 2.1 if this proves to be relevant.)

Have you ever experienced something similar? Is there a fix or a workaround?

Best Solution

Migrating most of the project to NHibernate (and thus completely avoiding Visual Studio's Dataset Designer) was used as a "workaround" (very far around!)

One solution we considered was using another tool to generate typed DataSets. Another potential solution was to manually modify the DataSet's XSD file; However, it proved to be considerably laborious and error prone.

All of these solutions actually involve not using Visual Studio's Dataset Designer.