Sub Main() not running

vagueante

Active member
Joined
Feb 20, 2009
Messages
28
Location
Portugal
Programming Experience
10+
Hi,

I've added a sub main to my project, but no matter where i put it, it never runs.

I've tried in the main form with : Shared Sub Main() with and without the shared word

In a module and in a class. In vb.net 2003 it worked, so that must be some configuration that i'm missing or doing wrong. any idea?
Even with a test like this

Sub Main()
console.writeline("Test")
End Sub
 
Did you go into the project properties pages and declare that your "Startup Object" is "SSub Main" and not "FormWhatever"?
 
Did you go into the project properties pages and declare that your "Startup Object" is "SSub Main" and not "FormWhatever"?

Yes, but for doing that i have to uncheck "enable application framework ", and if i do that among other things i loose some things, like My object.
 
For Windows Application projects you normally just select the startup form, or as you say, you can disable "application framework" and set a custom Sub Main start routine. You don't loose My objects from this, only the framework properties you see listed. For Console applications the "appliation framework" is not relevant and you always set startup object to a Shared Sub Main or a module containing a Sub Main.
 
For Windows Application projects you normally just select the startup form, or as you say, you can disable "application framework" and set a custom Sub Main start routine. You don't loose My objects from this, only the framework properties you see listed. For Console applications the "appliation framework" is not relevant and you always set startup object to a Shared Sub Main or a module containing a Sub Main.

"My.Application.OpenForms" stoped working, i don't know if all stoped, but this has.
 
"My.Application.OpenForms" stoped working
That wouldn't surprise me, as the application framework manages the open forms. Other My.Application stuff is there. Application framework is generally just helpful, why do you need to set a different Sub Main than the one it does for you?
 
That wouldn't surprise me, as the application framework manages the open forms. Other My.Application stuff is there. Application framework is generally just helpful, why do you need to set a different Sub Main than the one it does for you?

I have a problem, that i've put in another Post, and i'm trying to see if the problem is the workingdir of the app, briefly, an window app run's not visible, and only with a notifi icon, and from time to time it needs to open a form to ask the user for some input, and if the user is not a admin of the machine or domain admin the form.show doesn't work and no error, just don't open.

Creating a sub main was just to make sure i would change the workingdir the sooner the best.
 
Try this:

Open your My Project and uncheck "Enable application framework"

On your Form1 do the following:

VS 2008

VB.NET:
Friend Class Form1
  Shared Sub Main
    Dim loginfrm As New LoginFrm 'this will show first login form
    loginfrm.Showdialog()

    Dim frm1 As New Form1 'this will show after successful login
    frm1.Showdialog()
  End Sub

End Class
 
c0defr3ak, when starting an application that way use Application.Run to ensure correct start and stop of message pump.
You also still have default forms with application framework turned off.
 
My problem still not solved.

To resume:
My app use a notifiicon to run hidden from everyone :
VB.NET:
Me.WindowState = FormWindowState.Minimized
Me.ShowInTaskbar = False
If i choose the form as tool, it doesn't show in alt-tab, but in this case it shows in the lower left corner a little bar, that if i double click shows the main form, i've removed , controlbox, text (it just shows a grey little bar).

Is there a way of create a Windows application, that when in "notifiyicon mode", doesn't show in any other place, desktop. alt-tab, without using the Me.HIDE property ?

Finally i'll try to explain what's happening in my app right now.
In the winlogon, it runs my app, that has to run without the user being able to see it except for the notifyicon, and has to show some alert form with several messages, according to a timetable, and after the alert form, it must put the computer in standby. But now in the first "alert" of the day, it doesn't show the forms, but does ths stand by, after that, even if i shutdown the computer and restart it, will always work as i want, through the other "stand by needs", the problme it's the first tine of the day, when the only diference being some possible changes from the domain politics/software/upgrades.

The first time in the day it may upgrade some politic of the domain, but that shouldn't interfere with the form showing or not, right?
I'm really lost
 
Back
Top