Main not called

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi!

I have a problem with a .NET app that fails to start for some unknown
reason. The Main method is not called at all, which -- needless to say --
prevents the app from starting.

Any ideas why the Main-method isn't called?

Thanks in advance,
Nille
 
I can't post the actual code, as I don't own the rights to it. But I reduced
the main-method to something like this (C#):

public static void Main(String[] args) {
System.IO.StreamWriter writer = new
System.IO.StreamWriter(File.Create(path));
writer.WriteLine("Main method was invoked");
writer.Flush();
writer.Close);
}

where path should be /My Documents/Test.txt (translate my documents to a
language of your choice).

Ideally, there should be a file test.txt under my documents. If something
goes wrong, an IOException should be thrown. In reallity, there's nothing.
The Main-method is never invoked, but instead the nice "Loading
application"-animation never stops.

This doesn't occure on most platforms. I haven't been able to recreate it on
a device on my own, but rely on customer feedback.

If you find any errors in the code above, that should be a typo. It works as
expected on my device.

Regards,
Andreas Nilsson
 
So you can't post the actual code, if we find any errors on the code you
posted we should ignore them (like where is path defined and why you are not
tryCatching that) and you can't even replicate this on your own device,
right?

If I got the above right, then I cannot suggest that you stick a breakpoint
on the first line in Main to see if it is actually running nor can I advise
on using a MessageBox rather than a text file if you'd like to verify it
while not under the debugger. I guess, you have checked that your customer's
device is running the same framework version as yours and has enough memory;
try sending them another simpler CF app to see if it is a problem with the
device configuration rather than your specific app.

Also note that in Main you are supposed to do as little as possible (i.e.
just Application.Run(new Form1)). Were you doing that, the next step would
be to see if the ctor of Form1 was too long for the CF JIT. For more on
simple Mains read this:
http://wintellect.com/WEBLOGS/wintellect/archive/2005/03/30/941.aspx

Once you get a small reproducible sample or are willing to share the entire
Main (and/or more info), feel free to post back.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Nille said:
I can't post the actual code, as I don't own the rights to it. But I
reduced
the main-method to something like this (C#):

public static void Main(String[] args) {
System.IO.StreamWriter writer = new
System.IO.StreamWriter(File.Create(path));
writer.WriteLine("Main method was invoked");
writer.Flush();
writer.Close);
}

where path should be /My Documents/Test.txt (translate my documents to a
language of your choice).

Ideally, there should be a file test.txt under my documents. If something
goes wrong, an IOException should be thrown. In reallity, there's nothing.
The Main-method is never invoked, but instead the nice "Loading
application"-animation never stops.

This doesn't occure on most platforms. I haven't been able to recreate it
on
a device on my own, but rely on customer feedback.

If you find any errors in the code above, that should be a typo. It works
as
expected on my device.

Regards,
Andreas Nilsson

Daniel Moth said:
Shows us the Main (paste it here)

Cheers
Daniel
 
Back
Top