CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13
  1. #1
    Join Date
    May 2011
    Posts
    44

    Help with Debugging C# Project

    I am working on a project, and I thought I had it set up properly, but it is throwing a couple of debug errors, and I am not sure what to do to fix them, so I am reaching out for some assistance here.

    I am attaching a zip of my project in hopes that someone can assist, but I am sure someone can shed some insight on my errors, as you guys always do!
    Attached Files Attached Files

  2. #2
    Join Date
    Jun 2011
    Location
    .NET4.0 / VS 2010
    Posts
    70

    Re: Help with Debugging C# Project

    Link that might help you out:
    http://stackoverflow.com/questions/3...nd-inheritance
    Just scroll down to the answer marked as correct.

    As for the two entry points error it has to do with you having program.cs and program2.cs. The one you should be using is the one that runs your main form so in this case program2.cs has Application.Run(new FrmAirplane()); and excluding program.cs from your project.

  3. #3
    Join Date
    May 2011
    Posts
    44

    Re: Help with Debugging C# Project

    So if I understand the link correctly, I need to use this syntax:

    Code:
    class Base 
    {
    	// in my base class use this
      protected virtual string GetMood() {...}
    }
    
    
    class Derived : Base
    {
    	// in child class use this
      protected override string GetMood() {...}
    }
    Is that correct?
    Last edited by jo15765; August 5th, 2011 at 07:37 AM.

  4. #4
    Join Date
    Jan 2010
    Posts
    1,133

    Re: Help with Debugging C# Project

    Yes, for methods to be overridden, they need to be marked as virtual (if they have a base class implementation), or abstract (if they don't, and are required to be implemented in a derived class).

    I didn't download your zip, but know that, if there are relatively few errors, it often helps to post them here - their actual text, that is. It'll get easier to debug them yourself with experience, as C# compiler error messages are generally very descriptive and right on spot.

  5. #5
    Join Date
    May 2011
    Posts
    44

    Re: Help with Debugging C# Project

    That must be what the issue is then, because I did not do that in my project. I will add those features in, and report back once I get home from work, and have had a chance to add those elements.

    And thanks for the info, I will for future reference just post as a .txt file when I am having small issues like these.

    Until this evening......

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Help with Debugging C# Project

    Personally I would rather seeing someone include zipped project rather than a txt file. If I want to try to compile and run a text file, I have to take my precious time to create a project, copy the txt file context into it and so on. With a zipped project, I can just unzip it and load the project.

    For small code snippets, just put the code in [code][/code] code tags directly.

    At any rate, I've opened the project and found that you have an extra main function. In the Solution explorer, just select the "Program2.cs" file, right click and choose "Exclude From Project".

    That will get rid of the duplicate main compile issue.

  7. #7
    Join Date
    May 2011
    Posts
    44

    Re: Help with Debugging C# Project

    Oh I didn't even know you could do the "Exclude from Project"

    That's great to know, because I was wanting to somehow add in about 4 - 5 different "Main" (basically copy all of my files from previous projects, and house into a "Master" project, and still have the current project I am running compile with no errors) but I knew that would throw some big issues, with the Exclude from Project I may still be able to dot hat.

  8. #8
    Join Date
    Jan 2010
    Posts
    1,133

    Re: Help with Debugging C# Project

    Quote Originally Posted by jo15765 View Post
    And thanks for the info, I will for future reference just post as a .txt file when I am having small issues like these.
    Oh, I meant to post the text of the error message directly - not in a txt file, along side your code snippets (use [CODE][/CODE] tags for those). Sometimes, we don't need to run the code to see what's wrong. But if it's a major issue (by your own criteria - something you're really struggling with), then it's better to attach the project, as there could be some errors and code interactions you're not even aware of.

  9. #9
    Join Date
    May 2011
    Posts
    44

    Re: Help with Debugging C# Project

    Oh okay, thanks for the clarification. These were minor issues, but I didn't even think of just pasting in what the debug issues were.

  10. #10
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Help with Debugging C# Project

    Quote Originally Posted by jo15765 View Post
    Oh okay, thanks for the clarification. These were minor issues, but I didn't even think of just pasting in what the debug issues were.
    Just to be pedantic, I want to clarify the semantics.

    What you have is compile errors, which technically aren't debug issues.

    Compile issues are errors that occur while you are compiling your program.

    Debugging occurs after you are able to successfully compile. Debugging is running your program under a debugger so you can step through and inspect variables while the program is running.

  11. #11
    Join Date
    May 2011
    Posts
    44

    Re: Help with Debugging C# Project

    Arjay thanks for the definitions of Debugging and Compiling, I honestly thought that any issue preventing your program from running was a debugging issue! Show's my newbieness.

  12. #12
    Join Date
    Jan 2010
    Posts
    1,133

    Re: Help with Debugging C# Project

    If it doesn't compile, then it's like it doesn't exist - the processor has no clue what all the program code you've written means. As far as the CPU is concerned, it's just text files. It needs translation, and the compiler does that.

    Now, after it compiles and runs, a faulty program can crash, or worse, it can appear to work, when in fact it doesn't do what it is supposed to. A program can be complex, and it's various parts can interact in unpredicted ways. That's where the debugger comes in - it allows you to see what is it that your program is actually doing, what lines throw exceptions, what are the values of variables and parameters, how and why they change, and ultimately, it allows you to figure out how to rewrite the code so that it does what it's supposed to do.

  13. #13
    Join Date
    May 2011
    Posts
    44

    Re: Help with Debugging C# Project

    Alrite, so I fixed all compile and debug errors, but now I have a few other ?'s.

    For those of you who have looked at the project.....
    Since uploading I added a combo box on the form with 3 choices to choose from and I want whichever option the user chose to display in the textbox on the rightside of the form (The message will displayhere box)
    What code and Where in my existing code do additions need to be made in order to make this happen?




    How do I correct this?
    Last edited by jo15765; August 7th, 2011 at 04:37 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured