|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Hepl! No accessible 'Main' method with an appropriate signature was found ...I am trying to program an app that resides in the system tray and I am trying to put all my main code in sub Main(). I am getting this errormessage at compile: Performing main compilation... vbc : error BC30737: No accessible 'Main' method with an appropriate signature was found in I have done some post searching that has mentioned setting the project properties entry point to sub main() and I have tried that with no luck. I have tried placing my sub just about everywhere with hopes that the error would go away. Right now it resides right under the "Windows Form Designer generated code" section. Here is my sub, any help is greatly appreciated. Public Sub Main(ByVal cmdArgs() As String) Dim RegEntry = GetNzbDirFromReg() Dim Verified = VerifyDir(RegEntry) If Verified = False Then MessageBox.Show("Can not locate your config. Please make sure the application is installed. Exiting.", "Blah", MessageBoxButtons.OK) Application.Exit() End If ' GetPaths() If ComPath.Length < 1 Then MenuItem16.Enabled = False End If If InComPath.Length < 1 Then MenuItem17.Enabled = False End If foxCheck() AddHandler t.Elapsed, AddressOf TimerFired End Sub
Show quote
Hide quote
"Paulers" <SuperG***@gmail.com> schrieb: => 'Public Shared Sub Main(...)'.> I am trying to program an app that resides in the system tray and I am > trying to put all my main code in sub Main(). I am getting this > errormessage at compile: > > Performing main compilation... > vbc : error BC30737: No accessible 'Main' method with an appropriate > signature was found in > > I have done some post searching that has mentioned setting the project > properties entry point to sub main() and I have tried that with no > luck. I have tried placing my sub just about everywhere with hopes that > the error would go away. Right now it resides right under the "Windows > Form Designer generated code" section. Here is my sub, any help is > greatly appreciated. > > Public Sub Main(ByVal cmdArgs() As String) -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Thank you for such a quick reply! I added the shared and I am now
getting more errors of a OOP nature. Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class. I am searching for some posts regarding this topic but so far I have not been able to get anything to work. here are some of my functions it has a problem with. Public Function SetNzbPath() As String FolderBrowserDialog1.Description = "Please select the directory containing SABnzbd.exe" If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then NZBfolder = FolderBrowserDialog1.SelectedPath Return NZBfolder End If End Function Public Function VerifyDir(ByVal NZBfolder) As Boolean If Not System.IO.File.Exists(NZBfolder + "\SABnzbd.ini") Then If Not System.IO.File.Exists(SetNzbPath() + "\SABnzbd.ini") Then Return False Else Return True End If End If End Function Public Function GetNzbDirFromReg() As String Dim regKey As RegistryKey regKey = Registry.LocalMachine.OpenSubKey("Software\Paulers Software Works\", True) Return regKey.GetValue("NZBfolder") End Function "Paulers" <SuperG***@gmail.com> schrieb: Cut the code which is currently placed in your 'Sub Main' and add it to the > Cannot refer to an instance member of a class from within a shared > method or shared member initializer without an explicit instance of the > class. I am searching for some posts regarding this topic but so far I > have not been able to get anything to work. here are some of my > functions it has a problem with. form's constructor right after the call to 'InitializeComponent'. Then either remove 'Sub Main' completely and set the form as startup object or add the code below to 'Sub Main': \\\ Application.Run(New MainForm()) /// -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Thanks so much for all your help. that seemed to do the trick however
there is one small issue. I am doing an Application.Exit() and the program skips passed it like it was not there. I also tried a me.Close and the same thing happened. Are there any other ways to terminate the application? Thanks so much for all your help. that seemed to do the trick however
there is one small issue. I am doing an Application.Exit() and the program skips passed it like it was not there. I also tried a me.Close and the same thing happened. Are there any other ways to terminate the application? "Paulers" <SuperG***@gmail.com> schrieb: 'Me.Close()' should be sufficient. 'Application.ExitThread' should work > that seemed to do the trick however > there is one small issue. I am doing an Application.Exit() and the > program skips passed it like it was not there. I also tried a me.Close > and the same thing happened. Are there any other ways to terminate the > application? too. I suggest to set a breakpoint on the call to 'Me.Close()' and check if it gets called. If this doesn't solve the problem, you could post relevant parts of the source code. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> I set a breakpoint on me.close and the application did not break. Could
it be because I am trying to exit the application previous to the form designer completing its work? Here is the code. Thanks! #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() Dim regKey As RegistryKey Dim ChosenPath As String NotifyIcon1.Text = "WinSABnzb" regKey = Registry.LocalMachine.OpenSubKey("Software\Paulers Software Works\", True) If System.IO.File.Exists((Trim(regKey.GetValue("NZBfolder"))) + "\SABnzbd.ini") = False Then FolderBrowserDialog1.Description = "Please select the directory containing SABnzbd.exe" If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then ChosenPath = FolderBrowserDialog1.SelectedPath End If If System.IO.File.Exists(Trim(ChosenPath) & "\SABnzbd.ini") = False Then MessageBox.Show("WinSABnzb can not locate your SABnzbd.ini. Please make sure SABnzbd is installedin the directory specified. Exiting.", "About WinSABnzb", MessageBoxButtons.OK) Application.Exit() Me.Close() Application.ExitThread() Else NZBfolder = Trim(ChosenPath) regKey.SetValue("NZBfolder", NZBfolder) End If Else NZBfolder = Trim(regKey.GetValue("NZBfolder")) regKey.SetValue("NZBfolder", NZBfolder) End If GetPaths() If ComPath.Length < 1 Then MenuItem16.Enabled = False End If If InComPath.Length < 1 Then MenuItem17.Enabled = False End If foxCheck() 'Add any initialization after the InitializeComponent() call AddHandler t.Elapsed, AddressOf TimerFired t.Enabled = True End Sub "Paulers" <SuperG***@gmail.com> schrieb: I suggest to decouple startup code from the form code by moving it to 'Sub >I set a breakpoint on me.close and the application did not break. Could > it be because I am trying to exit the application previous to the form > designer completing its work? Here is the code. Thanks! Main': \\\ If <did some startup stuff successfully> Then Application.Run(New MainForm()) End If /// You won't need to close any forms and the application will exit automatically if startup was not successful. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> hi again Herfried,
I am in the process of moving my checks to main() and one thing I noticed is the functions that I called previously do not work anymore. they appear highlighted with the explicit error message that I mentioned in previous posts "Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class." I also noticed that the variables I had declared globaly (at the very top) are no longer visable. Can you show me an example of how I would create an explicit instance of a function? Thanks :)
Q: primary key
OK....forget the code...how about some pointers? API confusion "Global" Class Library: Best Practices? Threading question.... Problem with objects and automatic numbering in VB.NET Detect if user is logged in ADO.NET now or LINQ later Setting Individual Pixel Colors in VB 2005 [VB.NET 2005] - Irc OCX |
|||||||||||||||||||||||