Error XS1558 ('IMap.Exe.Functions' does not have a suitable static Main method)

This forum is meant for questions and discussions about the X# language and tools
George
Posts: 106
Joined: Thu Nov 05, 2015 9:17 am

Error XS1558 ('IMap.Exe.Functions' does not have a suitable static Main method)

Post by George »

Hi,

two of my projects (dated since 2010), use the IMapClient control of SocketTools library.
The first (the biggest) project is a Windows Service and it compiles correctly with X# 2.0.1.0.

The second is a small project that uses also the same library control.
The problem here is that the compiler produces the error:

Severity Code Description Project File Line Suppression State
Error XS1558 'IMap.Exe.Functions' does not have a suitable static Main method IMap XSC 1

so, the compiler doesn't report source code: The XSC line 1 is a generic error i suppose.

The code (in both projects) is:

LOCAL oIMAP AS SocketTools.IMapClient
LOCAL SocketToolsLicenseKey := "SomeSocketKey" AS STRING

oIMAP := SocketTools.IMapClient{}
IF ! oIMAP:Initialize(SocketToolsLicenseKey)
...
ENDIF


I don't know where to look at, because the references are identical to two projects and both projects compile correctly with previous version X# 2.0.0.8.

George
George
Posts: 106
Joined: Thu Nov 05, 2015 9:17 am

Error XS1558 ('IMap.Exe.Functions' does not have a suitable static Main method)

Post by George »

to be precise, the line:
LOCAL SocketToolsLicenseKey := "SomeSocketKey" AS STRING
added by me to the provided code sample.

In reality, the first project has the variable:
PUBLIC GLOBAL SocketToolsLicenseKey AS STRING

while the second project inherits the variable from a referenced DLL library which contains global definitions.

This is the only difference for the 2 projects.

George
User avatar
Chris
Posts: 4906
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Error XS1558 ('IMap.Exe.Functions' does not have a suitable static Main method)

Post by Chris »

Hi George,

The message means that there's no Start() function in your app suitable as an app start up point. It is so obvious, but we never thought about this before, to change the message to mention "Start" instead of "Main" (the c# way), will log this to be looked at.

So the error is reported either because you incorrectly set the project to "Console" or "WinApp" instead of "Library", or the Start() function is not correct. Try specifying as FUNCTION Start() AS VOID STRICT, does it work this way?
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
George
Posts: 106
Joined: Thu Nov 05, 2015 9:17 am

Error XS1558 ('IMap.Exe.Functions' does not have a suitable static Main method)

Post by George »

Chris,

>So the error is reported either because you incorrectly set the project to "Console" or "WinApp" instead of "Library"
The project was correctly VulcanDialect / WinApp

> or the Start() function is not correct
The Start() method is:
FUNCTION __XsStart(asCmdLine AS STRING[]) AS INT
because the Start(asCmdLine AS STRING[]) AS INT
didn't work for X# 2.0.0.8 when obfuscating with .NET Reactor.

>Try specifying as FUNCTION Start() AS VOID STRICT, does it work this way?
This way the project compiles, but the App not run after obfuscation (same problem with X# 2.0.0.8).

Here is the code (not working when obfuscation)
[STAThread] ;
FUNCTION Start(asCmdLine AS STRING[]) AS VOID STRICT
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault( FALSE )

TRY
DoRealStart(asCmdLine)
CATCH e AS Exception
System.Windows.Forms.MessageBox.Show(e:Message)
END TRY
RETURN

FUNCTION DoRealStart(asCmdLine AS STRING[]) AS VOID STRICT
Application.Run( Form1{} )
RETURN

Please note I followed your suggestion to change the Start() to __XsStart() in order to bypass the problem.
Now, this also is not working.

regards

George
User avatar
Chris
Posts: 4906
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Error XS1558 ('IMap.Exe.Functions' does not have a suitable static Main method)

Post by Chris »

OK, I see. I do not know the details of why the obfuscating failed so Robert tried to fixed it in the last build, will let him comment on that, but I think the best solution really is to put all your important code in a separate library that you will obfuscate and as a starter app use a very simply non-obfuscated .exe that only has one line of code to call a method in the library. I think this will take care of all the related issues.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
George
Posts: 106
Joined: Thu Nov 05, 2015 9:17 am

Error XS1558 ('IMap.Exe.Functions' does not have a suitable static Main method)

Post by George »

Chris,

I think this isn't the best way to change about 80 Projects to convert them to DLLs and create another 80 start up apps!
I am not happy this way.

regards
George
George
Posts: 106
Joined: Thu Nov 05, 2015 9:17 am

Error XS1558 ('IMap.Exe.Functions' does not have a suitable static Main method)

Post by George »

Please also note that the Windows Service App has:

FUNCTION Start() AS VOID

and worked fine obfuscated in X# 2.0.0.8 as opposed to the application.

George
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Error XS1558 ('IMap.Exe.Functions' does not have a suitable static Main method)

Post by robert »

George,
The workaround with the __XsStart function should no longer be needed.
What is the problem you see when you create a normal Start() function and obfuscate this.
Can you do a simple console program and compile and obfuscate this and send me the result ?

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
George
Posts: 106
Joined: Thu Nov 05, 2015 9:17 am

Error XS1558 ('IMap.Exe.Functions' does not have a suitable static Main method)

Post by George »

Robert,

the sample project contains only the default Start() created by X# (Vulcan Application template):
FUNCTION Start() AS VOID STRICT
LOCAL cbMacro AS CODEBLOCK
LOCAL cMacro AS STRING
cMacro := "{||DTOC(Today())}"
cbMacro := &(cMacro)
Console.WriteLine("Hello World today is " + (STRING) Eval(cbMacro))

Console.WriteLine("Press any key to continue...")
Console.ReadKey()

The error is related to: cbMacro := &(cMacro)

and the results:
C:UsersGeorgesourcereposDEBUGConsoleStart_Secure>consolestart

Unhandled Exception: Vulcan.Error:
Vulcan.NET Runtime Error

Error Code: 32 [Corruption detected]
Subsystem: BASE
Function: EVALUATE
Argument: Could not load the macro compiler
Call Stack:
at VulcanRTFuncs.Functions.Evaluate(String macroExpression, Boolean voCompatibleSyntax)
at VulcanRTFuncs.Functions.Evaluate(String macroExpression)
at ConsoleStart.Exe.Functions.<>c.<Start>b__2_0() in C:UsersGeorgesourcereposConsoleStartProgram.prg:line 12
at ConsoleStart.Exe.Functions.Start() in C:UsersGeorgesourcereposConsoleStartProgram.prg:line 8

at VulcanRTFuncs.Functions.Evaluate(String macroExpression, Boolean voCompatibleSyntax)
at VulcanRTFuncs.Functions.Evaluate(String macroExpression)
at ConsoleStart.Exe.Functions.<>c.<Start>b__2_0() in C:UsersGeorgesourcereposConsoleStartProgram.prg:line 12
at ConsoleStart.Exe.Functions.Start() in C:UsersGeorgesourcereposConsoleStartProgram.prg:line 8

I suppose in WinApp should be a call or class instantiation in Start() method, but the App never runs, so I cannot see the reason.

George
George
Posts: 106
Joined: Thu Nov 05, 2015 9:17 am

Error XS1558 ('IMap.Exe.Functions' does not have a suitable static Main method)

Post by George »

Robert,

I changed my WinApp's properties to Console Application.

The error is:
Unhandled Exception: System.InvalidOperationException: SetCompatibleTextRenderingDefault must be called before the first IWin32Window object is created in the application.
at System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(Boolean defaultValue)
at IMap.Exe.Functions.<>c__DisplayClass2_0.<Start>b__0() in C:UsersGeorgesourcereposCommunicationServerIMapStart.prg:line 22
at IMap.Exe.Functions.Start(String[] asCmdLine) in C:UsersGeorgesourcereposCommunicationServerIMapStart.prg:line 17

The 2 code lines:
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault( FALSE )

are the firsr lines of the Start()

George
Post Reply