Single instance of program error

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

Guest

hi, i got this erro when i tried to use the code from
http://www.windowsformsdatagridhelp.com/default.aspx?ID=59135549-e5dd-4501-9526-343ac05a7617 to make sure i only had one instance of my program working:

vbc : error BC30737: No accessible 'Main' method with an appropriate
signature was found in 'Database'.

heres my code, just so u dont have to go to the website, its exactly the
same, ex copied and pasted

Public Class Form1
Inherits System.Windows.Forms.Form

''I cut out the windows generated code to save u guys the reading

Public Sub Main()

Dim owned As Boolean
Dim mut As New System.Threading.Mutex(True, "xvcjsdf67AS124#$3",
owned)
If owned Then
Application.Run(New Form1)
mut.ReleaseMutex()
Else
MessageBox.Show("A previous instance is already running")
End If

End Sub

#Region "Declarations"

Dim write As IniFile.IniFile

#End Region


End Class
 
nevermind i figured it out. for soem reason i needed to put in "Private
Shared Sub Main" not just "Private Sub Main"
 
Iwdu

You have to start forever with a shared class (a class that is forever in
your program and not instanced as an object). That can be in VBNet a Module
what is that in fact or

Public Class TheProgram
Public Shared Sub Main
...
End Sub
End Class

Than you choise in the project properties (Project Explorer right click) in
the box with what to start Sub Main

You can as well start with the inbuild (not in code as in C# however direct)
start with your first form, what is than a kind of mainpage.

There are more, I know that Jay has written that somewhere in this
newsgroup. I thought that he had seven methods.

I hope this helps,

Cor
 
Back
Top