Welcome Guest ( Log In | Click here to Register a free account now! )
Welcome to Bleeping Computer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.
Feb 11 2009, 07:33 PM
Post
#1
|
|
|
Member ![]() ![]() Group: Members Posts: 67 Joined: 7-November 08 Member No.: 253,916 |
CODE using System; but I got these errors:using System.Windows.Forms; using System.Drawing; namespace CSharpSchool { class HelloWinForm { static void Main () { Application.Run (new MyWindow ()); } } class MyWindow : Form { public MyWindow () : base () { this.Text = "My First Windows Application"; this.Size = new Size (300, 300); Label lblGreeting = new Label (); lblGreeting.Text = "Hello WinForm"; lblGreeting.Location = new Point (100, 100); this.Controls.Add (lblGreeting); } } } Error 1 Program 'C:\Documents and Settings\Bob\Local Settings\Application Data\Temporary Projects\HelloWinForm\obj\Release\HelloWinForm.exe' has more than one entry point defined: 'HelloWinForm.Test.Main()'. Compile with /main to specify the type that contains the entry point. C:\Documents and Settings\Bob\Local Settings\Application Data\Temporary Projects\HelloWinForm\Form1.cs 8 21 HelloWinForm Error 2 Program 'C:\Documents and Settings\Bob\Local Settings\Application Data\Temporary Projects\HelloWinForm\obj\Release\HelloWinForm.exe' has more than one entry point defined: 'HelloWinForm.Program.Main()'. Compile with /main to specify the type that contains the entry point. C:\Documents and Settings\Bob\Local Settings\Application Data\Temporary Projects\HelloWinForm\Program.cs 14 21 HelloWinForm Error 3 'HelloWinForm.Form1.Dispose(bool)': no suitable method found to override C:\Documents and Settings\Bob\Local Settings\Application Data\Temporary Projects\HelloWinForm\Form1.Designer.cs 14 33 HelloWinForm Feeding this into a search engine: "visual c#" "Compile with /main" yielded this link: Compiler Error CS0017 Visual C# Reference: Errors and Warnings. Compiler Error CS0017 ... Compile with /main to specify the type that contains the entry point. ... msdn.microsoft.com/en-us/library/t9k01y87.aspx which said: If you are using MS Visual Studio and do not want to delete the other Main() methods you can specify the class which you want as you Entry Point in Startup Object in the Project Properties under Application Tab (at least for VS2008 Express) Going to: Project | HelloWinForm Properties | Application | Startup Object I discovered it wasn't set. Setting it to either HelloWinForm.Test or HelloWinForm.Program, the first two problems disappear, but not the third. I can't see how this code has more than one entry point, and I'm not at all clear on why the compiler requires these gyrations in Startup Object. None of these issues are mentioned by CSharpSchool, which claims the code I used will run as written. This is my first Windows app, and WOW! am I in the dark on this. What gives? Maybe I should just get a different tutorial. Any explanations of this or, failing that, any suggestions for which tutorial(s) I should use? |
|
|
|
![]() |
Feb 11 2009, 08:06 PM
Post
#2
|
|
![]() Look buddy -- I'm an Engineer ![]() ![]() ![]() ![]() ![]() ![]() Group: HJT Team Coach Posts: 8,518 Joined: 17-January 08 From: Northfield, Ohio Member No.: 184,215 |
The code you have listed here is written for you by the windows forms designer, and needs only be there if you aren't using the windows forms designer.
The compiler is complaining because it doesn't know which starting function to call -- your main() or the function inside the form. Billy3 -------------------- The forum is always a busy place. In the event I fail to reply within twenty-four hours, feel free to send me a PM.
Have I helped you? If so, please consider a donation (by clicking this link). And that means I solve problems. Not problems like "What is beauty?" .. 'cause that would fall under the purview of your conundrums of philosophy.... |
|
|
|
Feb 19 2009, 10:15 AM
Post
#3
|
|
|
Forum Addict ![]() ![]() ![]() ![]() ![]() ![]() Group: BC Advisor Posts: 1,417 Joined: 6-July 08 From: South Garden Member No.: 220,807 |
The code compiles without any problem using Visual Studio 2005. I used command line compiler "csc hello.cs" where "hello.cs" is the source code file. Maybe the express edition is causing the problem.
-------------------- |
|
|
|
Feb 19 2009, 05:20 PM
Post
#4
|
|
![]() Look buddy -- I'm an Engineer ![]() ![]() ![]() ![]() ![]() ![]() Group: HJT Team Coach Posts: 8,518 Joined: 17-January 08 From: Northfield, Ohio Member No.: 184,215 |
He's not compiling with the command line. The forms designer has a main() and you declared a main(). The compiler doesn't know which main() to call.
This post has been edited by Billy O'Neal: Feb 19 2009, 05:20 PM -------------------- The forum is always a busy place. In the event I fail to reply within twenty-four hours, feel free to send me a PM.
Have I helped you? If so, please consider a donation (by clicking this link). And that means I solve problems. Not problems like "What is beauty?" .. 'cause that would fall under the purview of your conundrums of philosophy.... |
|
|
|
![]() ![]() |
| Lo-Fi Version | Time is now: 26th November 2009 - 11:58 AM |