[Mono-devel-list] CodeEntryPointMethod doesn't work as expected

Lorenzo lcq2 at libero.it
Thu Jul 15 06:13:18 EDT 2004


Hi, this is my first post on this mailing list, so, hello to everyone :)
I'm having some troubles with the CodeEntryPointMethod class, which 
doesn't generate the corrent code with mono. Using this class with .NET 
I get this code:

public static void Main() {
...;
}

which works without problems, now if I use the same class with mono, I 
get the following code:
void Main() {
...;
}

which of course causes a compiler error, because the compiler can't find 
the entry point.
I've found a workaround for this by setting the Attributes property of 
the class, like this:
CodeEntryPointMethod start = new CodeEntryPointMethod();
start.Attributes = MemberAttributes.Public | MemberAttributes.Static;

and I get the correct code, but this should be done in the 
CodeEntryPointMethod constructor inside CodeEntryPontMethod.cs which is 
currently empty:

public class CodeEntryPointMethod
        : CodeMemberMethod
{
}

or it can be done in the CSharpCodeGenerator class, inside the 
GenerateEntryPointMethod method, which currently only sets the name to 
"Main":

protected override void GenerateEntryPointMethod( CodeEntryPointMethod 
method, CodeTypeDeclaration declaration )
{
     method.Name = "Main";
     GenerateMethod( method, declaration );
}

so something like method.Attributes = MemberAttributes.Public | 
MemberAttributes.Static; should work.
Let me know if this is a know bug and if there is another version of 
mono that fixes it (currently I'm using mono-1.0), if there aren't any 
version, I need to recompile the System namespace, because I'm using 
mono for a project and I need that class, so, can I recompile just the 
System namespace without rebuilding all the class libraries? How?

Thanks for your replies :)

Bye!!

Lorenzo



More information about the Mono-devel-list mailing list