use*_*745 5 c# visual-studio-2010
我有一个C#表单应用程序.我将一个额外的CS文件导入到程序中,现在它不再编译了.每次我尝试编译时都会收到以下消息:
Application does not contain a definition for 'EnableVisualStyles'
Application does not contain a definition for 'SetCompatibleTextrenderingDefault'
Application does not contain a definition for 'Run'
Run Code Online (Sandbox Code Playgroud)
当我点击错误时,它会将我带到Programs.cs.它只包含以下信息:
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激.
还有一点,测试控制台应用程序工作正常,但我希望这个应用程序是表单应用程序.
您using
为具有另一个定义的命名空间添加了一个新语句Application
(可能是您自己的)并且优先级高.您可以使用完全限定名称来确保定位到正确的Application
类:
global::System.Windows.Forms.Application.EnableVisualStyles();
global::System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
global::System.Windows.Forms.Application.Run(new Form1());
Run Code Online (Sandbox Code Playgroud)
(global::
只要你没有一个已经命名的类,你可以省略它,System
但是上面的模糊命名空间/类名称只是一个更强大的.
其他替代方法包括重命名自定义Application
类,如果它确实属于您自己的类,不using
为该文件(或任何使用System.Windows.Forms
Application
该类的文件)添加任何名称空间,添加别名System.Windows.Forms.Application
(这可以通过类似的方式完成using FormApplication = System.Windows.Forms.Application;
)等.
归档时间: |
|
查看次数: |
10039 次 |
最近记录: |