oleg-shilo / cs-script.net-framework

A mirror of the oleg-shilo/cs-script repository of CS-Script for .NET Framework. A copy of the repo before the product migration on .NET 5migrat
MIT License
30 stars 10 forks source link

hello_auto sample: Cannot find entry point #8

Closed megakraken closed 11 months ago

megakraken commented 11 months ago

Hello,

When trying to run the hello_auto.cs script with cscs /ac samples\hello_auto.cs I get the following error message:

Error: Specified file could not be executed.

System.ApplicationException: Cannot find entry point. Make sure script file contains method: 'public static Main(...)'
   at csscript.RemoteExecutor.InvokeStaticMain(Assembly compiledAssembly, String[] scriptArgs)
   at csscript.CSExecutor.ExecuteImpl()

I figured the /ac option should do the trick, what am I doing wrong?

For reference, the script looks like this:

using System;
using System.Windows.Forms;

void Main()
{   
    Console.WriteLine( "Hello World!" ); 
    MessageBox.Show( "Hello World!"); 
}
oleg-shilo commented 11 months ago

It is a defect. The auto-class generation algorithm is missing static modifier for the method.

I will do a quick fix but until it is available you can use lowercase main as a workaround:

using System;
using System.Windows.Forms;

void main()
{   
    Console.WriteLine( "Hello World!" ); 
    MessageBox.Show( "Hello World!"); 
}
oleg-shilo commented 11 months ago

Done. You can download the release from here: https://github.com/oleg-shilo/cs-script.net-framework/releases/tag/v3.30.7.0

megakraken commented 11 months ago

Great, thanks alot!