O'Reilly Forums: Debug? - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Debug? I am working through the book and i am stuck.

#1 User is offline   chessman007 

  • New Member
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 31-October 12

Posted 31 October 2012 - 02:13 PM

I am a complete newbie and I want to learn c#. i have started working through the book. I checked my work multiple times.
I am specifically on page 16 and i tried to run the debugger. For a few milliseconds, i saw a command line come up but nothing else. Then
the command line disappeared. And the debugging session stopped. the build succeeded and there were no errors. I don't know if this is a compatibility issue or if i did something wrong (probably the second of the two)
One thing that was different for me in Visual Studio Express 2010 was i had to create my own form by going to Project>>>add new windows form
Here is my code:

[u] Program.cs-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Contacts
{
    class Program
    {
        static void Main(string[] args)
        {
            
        }
    }
}



Form1.cs-
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Contacts
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Contact List 1.0. \nWritten by: NAME", "About");
        }
    }
}

0

#2 User is offline   Sikta_26785 

  • Active Member
  • PipPipPip
  • Group: Members
  • Posts: 67
  • Joined: 18-May 11

Posted 31 October 2012 - 04:52 PM

It sounds like you created a new console application instead of a new winforms project.

Your main thread in program.cs should look like this instead:

    [STAThread]
    static void Main()
    {
      Application.EnableVisualStyles();
      Application.SetCompatibleTextRenderingDefault(false);
      Application.Run(new Form1());
    }

0

#3 User is offline   chessman007 

  • New Member
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 31-October 12

Posted 02 November 2012 - 03:11 AM

View PostSikta_26785, on 31 October 2012 - 04:52 PM, said:

It sounds like you created a new console application instead of a new winforms project.

Your main thread in program.cs should look like this instead:

    [STAThread]
    static void Main()
    {
      Application.EnableVisualStyles();
      Application.SetCompatibleTextRenderingDefault(false);
      Application.Run(new Form1());
    }



Thank you very much!!! Now to page 17.....
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users