A
Andrus
When I try to open any of my Windows form in VS2008 windows form designer
which is based my Baseform class I got error
Unable to cast object of type 'FormData' to type 'FormData'.
Error message points to the method
public static T Load<T>(string id) where T : class {
IsolatedStorageFile store = IsolatedStorageFile.
GetUserStoreForAssembly();
Stream stream;
try {
stream = new IsolatedStorageFileStream(FileName(typeof(T), id),
FileMode.Open, store);
} catch (System.IO.FileNotFoundException) {
return null;
}
error line is
stream = new IsolatedStorageFileStream(FileName(typeof(T), id),
FileMode.Open, store);
This method is called from my base form Load event.
How to fix ?
Andrus.
Call Stack:
at MyApp.UserSettings.Load[T](String id) in
I:\MyApp\0 Util\Serialization.cs:line 107
at
MyApp.Windows.Forms.BaseForm.RestoreWindowState()
at
MyApp.Windows.Forms.BaseForm.BaseForm_Load(Object sender, EventArgs
e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean
fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.OnVisibleChanged(EventArgs
e)
at
System.Windows.Forms.ScrollableControl.OnVisibleChanged(EventArgs e)
at System.Windows.Forms.Form.OnVisibleChanged(EventArgs e)
at System.Windows.Forms.Control.SetVisibleCore(Boolean
value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at
System.Windows.Forms.Design.DesignerFrame.Initialize(Control view)
at
System.Windows.Forms.Design.DocumentDesigner.Initialize(IComponent
component)
at
System.Windows.Forms.Design.FormDocumentDesigner.Initialize(IComponent
component)
at
System.ComponentModel.Design.DesignerHost.AddToContainerPostProcess(IComponent
component, String name, IContainer containerToAddTo)
at
System.ComponentModel.Design.DesignerHost.Add(IComponent component, String
name)
at
System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.CreateComponent(Type
componentType, String name)
at
System.ComponentModel.Design.Serialization.DesignerSerializationManager.CreateInstance(Type
type, ICollection arguments, String name, Boolean addToContainer)
at
System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.CreateInstance(Type
type, ICollection arguments, String name, Boolean addToContainer)
at
System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager
manager, CodeTypeDeclaration declaration)
at
System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager
manager)
at
Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager
serializationManager)
at
Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32
fReload)
which is based my Baseform class I got error
Unable to cast object of type 'FormData' to type 'FormData'.
Error message points to the method
public static T Load<T>(string id) where T : class {
IsolatedStorageFile store = IsolatedStorageFile.
GetUserStoreForAssembly();
Stream stream;
try {
stream = new IsolatedStorageFileStream(FileName(typeof(T), id),
FileMode.Open, store);
} catch (System.IO.FileNotFoundException) {
return null;
}
error line is
stream = new IsolatedStorageFileStream(FileName(typeof(T), id),
FileMode.Open, store);
This method is called from my base form Load event.
How to fix ?
Andrus.
Call Stack:
at MyApp.UserSettings.Load[T](String id) in
I:\MyApp\0 Util\Serialization.cs:line 107
at
MyApp.Windows.Forms.BaseForm.RestoreWindowState()
at
MyApp.Windows.Forms.BaseForm.BaseForm_Load(Object sender, EventArgs
e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean
fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.OnVisibleChanged(EventArgs
e)
at
System.Windows.Forms.ScrollableControl.OnVisibleChanged(EventArgs e)
at System.Windows.Forms.Form.OnVisibleChanged(EventArgs e)
at System.Windows.Forms.Control.SetVisibleCore(Boolean
value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at
System.Windows.Forms.Design.DesignerFrame.Initialize(Control view)
at
System.Windows.Forms.Design.DocumentDesigner.Initialize(IComponent
component)
at
System.Windows.Forms.Design.FormDocumentDesigner.Initialize(IComponent
component)
at
System.ComponentModel.Design.DesignerHost.AddToContainerPostProcess(IComponent
component, String name, IContainer containerToAddTo)
at
System.ComponentModel.Design.DesignerHost.Add(IComponent component, String
name)
at
System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.CreateComponent(Type
componentType, String name)
at
System.ComponentModel.Design.Serialization.DesignerSerializationManager.CreateInstance(Type
type, ICollection arguments, String name, Boolean addToContainer)
at
System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.CreateInstance(Type
type, ICollection arguments, String name, Boolean addToContainer)
at
System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager
manager, CodeTypeDeclaration declaration)
at
System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager
manager)
at
Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager
serializationManager)
at
Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32
fReload)