我正在使用SharpDevelop和.NET 4.0。
我的问题是:如果您使用“Windows应用程序”模板启动一个新项目,它会生成一个Program.vb,其中包含以下内容:
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
但是,如果更改命名空间或类名,则会中断。我注意到该向导生成了一个Settings.settings文件...让我烦恼的是我似乎无法找到类扩展的来源。也就是说,如果更改/ /命名空间/类,则会出现构建错误,例如:
Program.vb(22,27) : Error BC30284: sub 'OnCreateMainForm'
cannot be declared 'Overrides' because it does not override a sub
in a base class.
换句话说,在我看来,代码应该是这样的:
Namespace My
Partial Class MyApplication
Inherits WindowsFormsApplicationBase
...
这里发生了什么?
答案 0 :(得分:1)
如果您从解决方案资源管理器重命名,那么您将没问题。
如果从类中重构,最终可能会在Class2.cs中定义Class1,这会令人恼火。
如果您只修改MyForm.cs,那么您还需要修改MyForm.Designer.cs,这是我怀疑您的问题所在。