Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"No accessible 'Main' method with an appropriate signature was found"

Status
Not open for further replies.

IlyaRabyy

Programmer
Nov 9, 2010
568
US
Colleagues,
(Just in case: Win10, VS 2019, .NET 5.0)
I have a set of commonly used UDFs ("User Defined Function", if someone don't know) in a separate project (as Console Application). I develop and code these functions and subs there, and then copy-paste them into my other project on As-Needed bases.
Needless to say that I need to test these functions and subs before using them in my other projects. E.g. if I have, say, Function Between(ByVal tArg, ByVal t1st, ByVal t2nd) As Boolean, I'd like to test it like
Code:
MsgBox(Between(2022, 2000, 2035))

and do it in that same project!

So, I added Sub Main() like this:
Code:
Imports System
Imports System.Net
Imports System.String
Imports System.IO
Imports System.Xml
Imports System.Threading
Imports System.Net.Mail
Imports System.Windows
Imports Microsoft.VisualBasic
Imports Microsoft.VisualBasic.FileIO
'====================================================================================================================================
Sub Main()
'====================================================================================================================================
End Sub
'====================================================================================================================================
'====================================================================================================================================
Public Class Common_Functions
...

set it as Startup object in Project's Properties ... and immediately got an error message "Statement is not valid in a namespace."

Alrite, I "encapsulated" it with Class/End Class, like this:
Code:
Imports System
Imports System.Net
Imports System.String
Imports System.IO
Imports System.Xml
Imports System.Threading
Imports System.Net.Mail
Imports System.Windows
Imports Microsoft.VisualBasic
Imports Microsoft.VisualBasic.FileIO

Public Class Func_Tester
'====================================================================================================================================
Sub Main()
'====================================================================================================================================

End Sub
'====================================================================================================================================
End Class
'====================================================================================================================================
Public Class Common_Functions
'====================================================================================================================================
...
and then got the error in subject line.
What am I doing wrong?
Please advise!

Regards,

Ilya
 
Found the solution!
Added Module Bla-Bla - and it works now.

Code:
Imports System
Imports System.Net
Imports System.String
Imports System.IO
Imports System.Xml
Imports System.Threading
Imports System.Net.Mail
Imports System.Windows
Imports Microsoft.VisualBasic
Imports Microsoft.VisualBasic.FileIO
'====================================================================================================================================
Module Common_Subs_Functions
'====================================================================================================================================
Sub Main()
'====================================================================================================================================
End Sub
'====================================================================================================================================

End Module
'====================================================================================================================================
'====================================================================================================================================
Public Class Common_Functions

Thank you all nonetheless!

Regards,

Ilya
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top