I’m using SharpDevelop and .NET 4.0.
My question is this: If you start a new project with a “Windows Application” template, it generates a Program.vb with the following contents:
Imports Microsoft.VisualBasic.ApplicationServices
Namespace My
' This file controls the behaviour of the application.
Partial Class MyApplication
Public Sub New()
MyBase.New(AuthenticationMode.Windows)
Me.IsSingleInstance = False
Me.EnableVisualStyles = True
Me.SaveMySettingsOnExit = True
Me.ShutDownStyle = ShutdownMode.AfterMainFormCloses
End Sub
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = My.Forms.MainForm
End Sub
End Class
End Namespace
However, if you change either the namespace or the class name, it breaks. I note that the wizard generates a Settings.settings file… What bothers me is that I can’t seem to find the source of the class extension. That is, if you change either/both namespace/class, you get build errors such as:
Program.vb(22,27) : Error BC30284: sub 'OnCreateMainForm'
cannot be declared 'Overrides' because it does not override a sub
in a base class.
In other words, in my mind the code should be something like:
Namespace My
Partial Class MyApplication
Inherits WindowsFormsApplicationBase
...
What is going on here?
Well if you rename from the Solution explorer you will be okay.
If you refactor from the class, you could end up with Class1 defined in Class2.cs, which would be irritating.
If you just amend MyForm.cs, then you also need to amend MyForm.Designer.cs, which is where I suspect your problem is.