Application.Run

B

Brett Wesoloski

I am new to VS2005.

I changed my program.cs file to be a different form I am working on. But
when I go to run the application it still brings up the form that was
originally declared as new. When I put in a break point the program does
not stop. It is in debug mode. If I change the program.cs file back to the
form that was originally being used. The program does go into debug mode.
But if I change code in that file it isn't using it. It is like the program
is using an old compiled version.

Any one know why this would be?

TIA,
Brett
 
B

Brett Wesoloski

Ok after sending this and reading it I didn't really describe what I was
trying to accomplish. Sorry about that.

I just want to change the start up form. I did look under the
projects-application properties but there is nothing to change. I would
expect it to be in the start up object but all that was there was
ProgramName.Program so I am assuming it is calling the program.cs class.
That is where I change teh Application.Run to be the different form.

So I guess am I evern looking in the right place to change the startup form?

TIA,
Brett
 
G

Guest

The form that is first shown when an application is run is usually the form
that is passed as the parameter to

Application.Run();

The first "Application.Run" called will be the first Application.Run called
after the method "Main".

Main is ALWAYS the first method that is run it's signature is (in a
WindowsApplication):

static void Main()
{

}

You cannot declare more than 1 "main" method or the compiler will whinge.

Look for the method "main" and you will find the first Application.Run()

Jax
 
B

Brian Gideon

Brett,

So you're saying that you did change the Application.Run line in the
static Main method? That should have worked. Can you post the code
from the Main method?

Brian
 
B

Brett Wesoloski

Ok well in the program.cs class I have

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new Login());

}



I have changed Applicaiton.Run() from

Application.Run(new Login());

to

Applicaiton.Run(new ShelfList()):

but it still brings up the Login screen. Also I can not debug the
application any more. If I leave it Login() then I can debug the app and it
goes to the Application.Run(new Login()); then brings up the form. So I
thought it would be as easy as changing the Login() to ShelfList()

It seems from what you are saying I was looking/working in the correct spot.

Any other idea's?

TIA,
Brett
 
B

Brett Wesoloski

Yes I did change the Application.Run line in the static Main method.

Here is my main code.

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new Login());

}



If I change Applicaiton.Run(new ShelfList()); then it doesn't work. Just
bypasses the code and brings up the Login().

Under the project properties - Applicaiton I have for startup object I have
programName.Program.


I have done a search through the whole project for another Main method but
nothing.

TIA,
Brett
 
B

Brett Wesoloski

Well I created a new project and was able to change it.

Something must have been messed up with the project.

Thanks,
Brett
 
S

Simon Tamman

Something was massively out of sync, were you running it from F5 in Visual
Studio or running the .exe and attaching the debugger?

If the debugger skips through the breakpoints thats a sure sign that what
you are debugging with and what you are debugging against do not match.
 
S

ssamuel

This is often just because debug files get messed up. This happens
sometimes for no apparent reason and is nowhere near dangerous. Delete
*.pdb from Debug\bin, recompile the whole project, and try again.


Stephan
 
J

justin creasy

Another thing to try is to clean the solution. To do this, go to the
"Build" menu and select "clean solution". Then rebuild the solution and
try running. Just a thought.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top