Wednesday, 28 September 2011

Visual Studio 2008 and the corrupt (ADO-based-only) Dataset Editor

I have been struggling with VS2008 and the DataSet Designer for the last .. nearly 24 hours.  I've got one project with 5x ADO Datasets and one Dataset that is not attached to a database via a connection string.  I've not had this project open for a while... during which the following events have happened:

1) SQL Server 2005 Security Update for SP3 (KB2494113) failed because I had to catch a train - leaving SQL Server 2005 Standard in a corrupt and un-runable state... I managed to attach the database I was working on into SQL 2008 Express - so I didn't lose much in time... I have left SQL 2005 in that state since today and successfully installed SQL 2005 SP4 which has revived my corrupt SQL Server and the database is still attached and working... (now to update it with changes since then)

2) Several VS2008 Post SP1 Updates - namely: KB2538241, KB2251487, KB971092... It looks like I have installed them about 10 times each... this was down to what I think was a fault with WindowsUpdate in that it kept on offering me the same updates over and over - even after a successful install.... I managed to fix those and some recurring Office 2007 Updates with the automated FixIt from:

So... now my VS2008 projects open, compile and run perfectly well... all except from trying to open them in the "DataSet Editor" (right click the DataSet and choose Open With... you'll see a list of options.  It's a poor design because despite the great amount of control you have over add-ins and developing for VS you aren't shown what actions are taken when you click on any of the items in this list.  My guess is that you have to check the registry...

I select DataSet Editor from the list and I get this helpful error message:

"Load DataSet Error:  Failed to load dataset because of the following error:  Illegal characters in path"

Er... what path?  Click ok and the panel is filled... "To prevent possible data loss before loading the designer, the following errors must be resolved: Illegal characters in path.  Show call stack:"

at System.IO.Path.CheckInvalidPathChars(String path)
at System.IO.Path.IsPathRooted(String path)
at Microsoft.VSDesigner.Data.Local.ConnectionStringConverter.ToRunTime(Project project, ConnectionString csToConvert)
at Microsoft.VSDesigner.VSDesignerPackage.AppSettingsHelper.AddServerExplorerConnections(IServiceProvider serviceProvider, IList connections)
at Microsoft.VSDesigner.VSDesignerPackage.GlobalConnectionService.Microsoft.VSDesigner.VSDesignerPackage.IGlobalConnectionService.GetConnections(IServiceProvider serviceProvider, Project project)
at Microsoft.VSDesigner.DataSource.DesignConnection.GetConnectionFromAppSettings(String objectName, String propertyName, Project currentProject)
at Microsoft.VSDesigner.DataSource.DesignConnection.GetConnectionStringObject(Project targetProject)
at Microsoft.VSDesigner.DataSource.DesignConnection.get_ConnectionStringObject()
at Microsoft.VSDesigner.DataSource.DbSource.set_Connection(IDesignConnection value)
at Microsoft.VSDesigner.DataSource.DesignDataSource.SetConnectionProperty(Source source)
at Microsoft.VSDesigner.DataSource.DesignDataSource.ReadXmlSchema(DataSourceXmlTextReader xmlReader)
at Microsoft.VSDesigner.DataSource.DesignDataSource.ReadXmlSchema(TextReader textReader)
at Microsoft.VSDesigner.DataSource.Designer.DataSourceSerializationService.DeserializeToDataSource(String filePath, Object serializationData)
at Microsoft.VSDesigner.DataSource.ProjectDataSourceDescriptor.LoadDataSource()
at Microsoft.VSDesigner.DataSource.ProjectDataSourceDescriptor.Init(IServiceProvider provider, IVsHierarchy primaryHierarchy, UInt32 primaryItemId, Object primaryDocDataObject, UInt32 docCookie, IVsInvisibleEditor invisibleEditor, IDesignerHost host)
at Microsoft.VSDesigner.DataSource.ProjectDataSourceStorage.EnsureInvisibleEditor(ProjectItem dsProjectItem, Boolean ensureWritable, Boolean createInvisibleEditor, Boolean getUIInfo)
at Microsoft.VSDesigner.DataSource.ProjectDataSourceStorage.GetDataSourceInternal(Object caller, ProjectItem dsProjectItem, Boolean ensureWritable, Boolean createInvisibleEditor, Boolean getUIInfo)
at Microsoft.VSDesigner.DataSource.Designer.DataSourceDesignerLoader.HandleLoad(IDesignerSerializationManager serializationManager)

Ok,, I get there's a problem... I created a new project, and a new dataset using another database, a different driver (SQL not Jet), the designer loaded and I added a few tables... close the designer... re-open the designer and the same error message appears...  so it's not something in the ConnectionString - because I can add tables to a new DataSet in the Designer... and it's not to do with the Designer because I can still create DataSets...

I have another DataSet that has some hand-built tables... none of the tables in the Dataset are from databases... and this DataSet loads into the Designer as expected... no problems...

A further curious addition to this problem... Double click on DataSet1.xsc (View All Files must be checked to see the auto-generated .XSC file)... I can see the XML, but now another message pops up:

"MS Visual Studio:  Package Load Failure
Package 'Microsoft.VisualStudio.XsdDesigner.Package.DesignerPackage' has failed to load properly ( GUID = {20AAF8FA-14C0-4897-8CA0-4D861E2B1212} ).  Please contact package vendor for assistance.  Application restart is recommended, due to possible environment corruption.  Would you like to disable loading this package in the future?  You may use 'devenv /resetskippkgs' to re-enable package loading."  Yes/No

No, thanks...   But there's a GUID.. before closing that message.. open Regedit... HK_Local Machine.. Software.. Microsoft.. Visual Studio.. 9.0 .. look down the list, I see Packages.. and 20AA ->

CodeBase = C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.XsdDesignerPackage.dll
InProcServer32 = C:\Windows\system32\mscoree.dll
MinEdition = Standard
ProductName = XML Schema Designer
ProductVersion = 1.0

Looks ok to me.. the file exists in that location - version 9.0.30729.1 - 30/07/2008.

I see people suggesting starting devenv with switches such as 'devenv /resetsettings' 'devenv /resetskippkgs', 'devenv /setup' ... I tried them all... I even ran 'devenv /log' to create a log of the problem... but the log doesn't show the right level of detail around the event... there are warnings about loading SpecExplorer, CodeRush and another third-party add-in... Refactor?.. but none of these should interfere with the Dataset Designer...

I have now tried, right-clicking on a dataset and choosing to "Run Custom Tool" ... but the custom tool, MSDataSetGenerator, throws the same 'Illegal characters in path' error and this leaves my project with over 100 errors... most of which are now: "Type 'SurveyDataSet' is not defined" "Type ttt is not defined"  - the first error is "Custom Tool Error: Failed to generate code.  Illegal characters in path" ...

Because I tried to open the XSC file and it played with the XsdDesigner.. I'm also getting this:

Warning  104  The 'urn:schemas-microsoft-com:xml-msdatasource:DataSetUISetting' element is not declared. C:\Data\Projects\Test1\Datasets\DataSet1.xsc

I can ignore that .. because once I press compile it'll all go away... Nope.. it didn't go away... I'll try restarting VS2008 - hmm still all 'not defined'... Check the recycle bin - and the DataSet1.Designer.vb file is in there!!  Restore, refresh the Solution Explorer and include DataSet1.Designer.vb in project... and all back to normal...  well to whatever 'normal' is defined as today at least...

So.. where is the problem?  It must be something the Designer is loading?  Because the designer loads, and only fails to continue loading if the database links to ADO... It's trying to read the XML Schema.. which then has to get the connection string.. it's getting the connection string from AppSettings... and then failing...

When I load app.config - I receive the above Package Load Failure - for XsdDesigner ... and now the error messages are picking up on schema information:

Message  Could not find schema information for the element 'userSettings'. C:\Data\Projects\Test\app.config

Message  Could not find schema information for the element 'Test.My.MySettings'. C:\Data\Projects\Test\app.config
[..... and so on... for 'setting' 'name' 'serializeAs' 'value' ... until the end of the file...]

One of the updates was a new XmlEditor file... MS11-049 Security Update for VS2008 SP1: June 14, 2011 (KB2251487).  This includes a new Microsoft.XmlEditor.dll ... no other supporting files... or changes to the Designer.. MS11-049 is really about XML throughout the Operating System... it affected SQL Server, VS and MSXML...  If the Editor were at fault, then I would have a problem with ALL datasets?

-------------------  FIXED -------------------
To cut this long story short... I fixed it... I decided to download the last Service Pack.. To re-install VS2008 SP1.  The Microsoft.XmlEditor.dll file above is still there, so it may not have overwritten newer files... but it has sorted out whatever was corrupted in the files, registry or oledb_services... I can now edit DataSets again...

In order to re-install VS2008 SP1... I had to clear out 4GBs off my hard disk.. SP1 requires about 5.6GB free space... and it's left me with 4.3GB free (there's half a gig in a folder called 'Microsoft Visual Studio 2008 SP1' in my temp folder.. I might just copy that to my spare disk - just in case..)

At least this exercise has introduced me to VS Packages, how they work... I've fixed my broken SQL Server 2005 Standard install... and had a few ideas about moving on... (upgrading projects to VS2010, moving VS2008 to a VirtualMachine, or having one VirtualMachine with VS2008 or VS2010 per client... and all their individual projects... I may only have bought myself a few more weeks... this Lenovo 3000 is nearing it's 'Use By' date anyway...

Back to work...

No comments:

Post a comment