Louise Boulton

Hi,

I'm getting the error below when I try to run my project. It's never happened before, and I don't understand what's caused it.

Can anyone help please

Thanks,

Louise

System.InvalidOperationException was unhandled
Message="An error occurred creating the form. See Exception.InnerException for details. The error is: The form referred to itself during construction from a default instance, which led to infinite recursion. Within the Form's constructor refer to the form using 'Me.'"
Source="FrontierIS"
StackTrace:
at FrontierIS.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190
at FrontierIS.My.MyProject.MyForms.get_frmData()
at FrontierIS.My.MyApplication.OnCreateMainForm() in D:\contacts\FrontierIS\My Project\Application.Designer.vb:line 35
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at FrontierIS.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()




Re: Windows Forms Designer Suddenly I'm getting this error: The form referred to itself during construction from a default instance

littleguru

Try to delete the bin and obj folders and recompile. That should help in most of the cases.




Re: Windows Forms Designer Suddenly I'm getting this error: The form referred to itself during construction from a default instance

Louise Boulton

Hi,

Thanks for the suggestion, I've tried it unfortunately I'm still getting the error.

Louise






Re: Windows Forms Designer Suddenly I'm getting this error: The form referred to itself during construction from a default instance

littleguru

From the exception message it seems as if you (in the constructor itself) create an instance of the form or call the constructor over and over again. Is that happening. If so, remove that part and use "Me" to reference to the current instance of the form.




Re: Windows Forms Designer Suddenly I'm getting this error: The form referred to itself during construction from a default instance

Louise Boulton

Thanks, I realised it was because I was declaring a new dataview in another form as a global object in that form, which referred to frmData. If I declare the dataview but leave it until the form's load event to supply its table, rowfilter etc the problem doesn't occur.

Thanks again for your help

Louise