Why does the code block below give a compile error of "does not contain a static 'Main' method suitable for an entry point"?
namespace MyConApp
{
class Program
{
static void Main(string args)
{
string tmpString;
tmpString = args;
Console.WriteLine("Hello" + tmpString);
}
}
}
Thus, if you are unlucky to encounter the error message saying “Entry Point Not Found”, it means that your operating system has no access to this program and then you can’t run it. If you want to fix this error, you can follow the possible fixed given below.
In computer programming, the first instructions of a program need to be executed through an entry point and the program can access to command line arguments through it. In order to start the execution of a program, the loader or operating system on your computer need to pass control to the entry point of this program.
When you are running an app, the Entry Point Not Found DLL error appears, you can also try this method. What you need to do is to uninstall the problematic app which triggers the Entry Point Not Found error from your computer and then reinstall it. The following part will show you how to uninstall an app from your computer.
But I am getting error stating "Main has the wrong signature to be entry point". Is there a better way to do this? "Main has the wrong signature to be entry point" means that Main need only one params
In the code you provide the problem is that the 'Main' entry point is expecting a array of strings passed from system when the program is invoked (this array can be null, has no elements)
to correct change
static void Main(string args)
to
static void Main(string[] args)
You could get the same error if you declared your 'Main' of any type other than 'void' or 'int'
so the signature of the 'Main' method has always to be
static // ie not dynamic, reference to method must exist
public // ie be accessible from the framework invoker
Main // is the name that the framework invoker will call
string[] <aName> // can be ommited discarding CLI parameters
* is the command line parameters space break(ed)
From MS (...) The Main method can use arguments, in which case, it takes one of the following forms:
static int Main(string[] args)
static void Main(string[] args)
Because the argument is String and not a String Array as expected
See this to understand Main
method signature options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With