Sunday, November 19, 2006

"One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while o"

Problem : "One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes" when you try to open DataSet in designer view

Key not valid for use in specified state.
Hide

at Microsoft.VisualStudio.Data.DataProtection.DecryptString(String s)
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)
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)
at Microsoft.VSDesigner.DataSource.ProjectDataSourceStorage.GetDataSourceInternal(Object caller, ProjectItem dsProjectItem, Boolean ensureWritable, Boolean createInvisibleEditor)
at Microsoft.VSDesigner.DataSource.Designer.DataSourceDesignerLoader.HandleLoad(IDesignerSerializationManager serializationManager)


Solution:
open the DataSet.xsd xml file (right mouse button on DataSet and press "View Code")and delete the connection string element


<Connection AppSettingsObjectName="Settings" AppSettingsPropertyName="XXXXX" ConnectionStringObject="" IsAppSettingsProperty="True" Modifier="Assembly" Name="YYYYY" ParameterPrefix="@" PropertyReference="ZZZZZ" Provider="System.Data.SqlClient" />

that works to me