xsharp.eu • Error XS1558 ('IMap.Exe.Functions' does not have a suitable static Main method) - Page 2
Page 2 of 3

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

Posted: Tue Apr 23, 2019 7:37 am
by robert
George,

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

Robert

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

Posted: Tue Apr 23, 2019 7:40 am
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

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

Posted: Tue Apr 23, 2019 9:58 am
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

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

Posted: Tue Apr 23, 2019 10:22 am
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

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

Posted: Tue Apr 23, 2019 10:31 am
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

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

Posted: Tue Apr 23, 2019 12:11 pm
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

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

Posted: Tue Apr 23, 2019 12:41 pm
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

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

Posted: Tue Apr 23, 2019 1:14 pm
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.

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

Posted: Tue Apr 23, 2019 1:37 pm
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

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

Posted: Tue Apr 23, 2019 1:49 pm
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.