473,386 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Hepl! No accessible 'Main' method with an appropriate signature was found ...

Hello vb.net experts :)

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

Jan 22 '06 #1
9 23752
"Paulers" <Su*******@gmail.com> schrieb:
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)

=> 'Public Shared Sub Main(...)'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Jan 22 '06 #2
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

Jan 22 '06 #3
"Paulers" <Su*******@gmail.com> schrieb:
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.


Cut the code which is currently placed in your 'Sub Main' and add it to the
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/>

Jan 22 '06 #4
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?

Jan 22 '06 #5
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?

Jan 22 '06 #6
"Paulers" <Su*******@gmail.com> schrieb:
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?


'Me.Close()' should be sufficient. 'Application.ExitThread' should work
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/>

Jan 22 '06 #7
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("NZBfo lder"))) +
"\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

Jan 22 '06 #8
"Paulers" <Su*******@gmail.com> schrieb:
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!


I suggest to decouple startup code from the form code by moving it to 'Sub
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/>

Jan 23 '06 #9
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 :)

Jan 23 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: opal7313 | last post by:
Hello, I have some difficulties to use phpMyAdmin on my ppc; I am working on panther 10.3.7 and php is already installed. I put phpMyAdmin directory in /Library/WebServer/Documents/ ; I adapted...
0
by: Patrick L. Nolan | last post by:
We have a python+Tkinter program that works properly on Linux, but when moved to Windows (XP) it behaves in a strange way. There's a section like this: (child_out, child_in) =...
2
by: Patrick L. Nolan | last post by:
We have an application that works on Linux. It has to be ported to Windows XP, and there's one bug that's driving me crazy. There's a number-crunching program written in C++. It is invoked by a...
2
by: Patrick L. Nolan | last post by:
I'm going nuts trying to port an application from Linux to Windows. We have a python/Tkinter script which runs a C++ application. It starts it with popen4 and communicates through the two pipes....
3
by: Patrick L. Nolan | last post by:
Our python script uses popen to run an application on Windows XP. The application chokes if the filename given as a command line argument contains any spaces. It's happy with the 8.3 shortname...
2
by: Patrick L. Nolan | last post by:
I'm trying to find a clean way to launch a Wordpad editor on Windows. By "clean", I mean that it should work on as many versions of Windows as possible, and it shouldn't require installing any...
4
by: Patrick L. Nolan | last post by:
Our Tkinter application has a big ScrolledText widget which is a log of everything that happens. In order to prevent people from making changes, we have it in DISABLED mode except when the...
5
by: Dmitry Bond. | last post by:
Hello. Our product works fine on all 7.x and 8.x DB2 versions. But stops to work on DB2 v9.1. The main problem is - duplicate primary key (sqlcode=-803) happens when inserting records in...
0
by: manjeet | last post by:
Hello everybody, I have a problum, i want to rewrite my file extention from .php to .html and also want to chang all the dynamic url into a static url. I have tryed the following option but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.