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
User avatar
robert
Posts: 4326
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,

Sorry, but I can't solve this without seeing the code and exe.

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 »

Hi Robert,

I will send you the project.
You will have only to download .NET Reactor 5 (as evaluation for 1 month)
or better, I will send you my .NET Reactor version to test with the same tools.

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,

preparing to send you my Project, I saw that a Reference to my huge Common.DLL is not really required because I call only some (3-4) methods, so I created a small Common Class inside my project with the required Methods.

Then, I tested and the application worked obfuscated.

Αfterward I removed the small Common Class and referenced again the Common.DLL.
By setting the project type to Console, after obfuscating I saw the error:
"SetCompatibleTextRenderingDefault must be called before the first IWin32Windows object is created in the application".

I removed the 2 lines from Start():
// Application.EnableVisualStyles()
// Application.SetCompatibleTextRenderingDefault( FALSE )
and then, the obfuscated app worked again.

I think there is some conflict in my Common.DLL with these 2 code lines (starting from X# 2.0.1.0).

Inspecting again the Common.DLL, I see there is a reference to a small CompanyLicense.dll where I put info for each customer separatelly. It contains some PUBLIC GLOBAL variables and one Function to initialize the variables.

The chain is:
Application references Common.DLL
Common.DLL references CompanyLicense.DLL

My logic is to create an App package (with .NET Reactor) having the App's EXE, the Common.DLL and the VulcanRT DLLs as EXE output in a common space in my Cloud update area.
Then I provide a CompanyLicense.dll to each customer and from time to time the customer checks for updates (from inside all my applications) and gets the new version from my Cloud update area.

So, I think something has changed in the DLL chain in version X# 2.0.1.0.

May-I remove the 2 code lines from Start() and continue this way ?
The App runs correctly. I cannot see any visual difference after removing the 2 code lines.

I am really confused.

George
User avatar
robert
Posts: 4326
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,
George wrote: May-I remove the 2 code lines from Start() and continue this way ?
The App runs correctly. I cannot see any visual difference after removing the 2 code lines.

I am really confused.
You ask me if you may remove the 2 lines of code ?
I really have no idea. It is your code ..

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,

many years ago, when started coding in .NET, these 2 code lines exists in all Start() functions.

Also, your default generated code (X# Windows Forms Application) when a WinApp created is:
[STAThread] ;
FUNCTION Start() AS VOID

Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault( FALSE )
Application.Run( Form1{} )

RETURN

That's why I am asking the question.
Why do you include then in the Start() ?

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 »

Anyway, I kept the line into the Start():
Application.EnableVisualStyles()

and removed the line:
Application.SetCompatibleTextRenderingDefault( FALSE )

this way the application works.

thanks
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 »

Hi,

after some Googling, I found this:
Trouble with Windows Forms, in method SetCompatibleTextRenderingDefault:
https://forums.autodesk.com/t5/revit-ap ... -p/7479941

regards
George
User avatar
Chris
Posts: 4633
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 »

George,

I suspect there's some code being executed before the main Start() body, either due to initialization of gloals as you pointed out, or maybe you have some _INIT procedures?

Try loading your .exe in ILSpy, does it completely obfuscate Start() as well? If you can see its code, check what else is being called before your actual first lines of code.
Chris Pyrgas

XSharp Development Team test
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 »

Hi Chris,

>check what else is being called before your actual first lines of code
Yes. There is something before.

ILSpy results (before obfuscator):

using System
using System.Windows.Forms

[STAThread];
public static method Start(asCmdLine as string[] ) as void
try
global::_003CModule_003E._0024AppInit()
action := { =>
Application.EnableVisualStyles()
try
DoRealStart(asCmdLine)

catch ex as Exception
MessageBox.Show(ex:Message)
end try
}
action()

finally
global::_003CModule_003E._0024AppExit()
GC.Collect()
GC.WaitForPendingFinalizers()
end try

internal static class _003CModule_003E
[CompilerGenerated];
internal static method _0024AppInit() as void
try
State.AppModule := typeof(IMap.Exe.Functions):Module
State.CompilerOptionFOvf := false
State.CompilerOptionOvf := false
State.CompilerOptionVO11 := false
Softway_Common.Functions._0024Init1()
VulcanRTFuncs.Functions._0024Init1()
IMap.Exe.Functions._0024Init1()

catch innerException as Exception
throw Exception{"Error when executing code in Vulcan INIT procedure(s)", innerException}
end try

[CompilerGenerated];
internal static method _0024AppExit() as void
Softway_Common.Functions._0024Exit()
IMap.Exe.Functions._0024Exit()
end class

thanks,
George
User avatar
Chris
Posts: 4633
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 »

Geore,

OK, so can you follow the code inside the calls

Softway_Common.Functions._0024Init1()
IMap.Exe.Functions._0024Init1()

is there a call somewhere there to code that uses anything else from windows forms? it must be something in there that causes the problem.

But, in any case, I think you can safely remove the cal to SetCompatibleTextRenderingDefault(), this was a think of the .Net 1.1 to .Net 2.0 era IIRC.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Post Reply