[Mono-winforms-list] Does not contain a static Main method su itable for an entry point

Stephen Quattlebaum stephen at covidimus.net
Thu Aug 17 16:39:34 EDT 2006


(Hans, I copied my reply to the list b/c it doesn't help anyone else to
resolve issues off-list.  However, this also isn't really a
winforms-specific bug, so if you need to ask further questions, try the
general dev list rather than the winforms one.)

Yeah, you've got to tell the compiler what other libraries to reference when
compiling something.  Namespaces and libraries are actually completely
separate -- you've got to tell the compiler about other libraries, and then
in addition you have to put appropriate 'using' declarations to tell the
compiler what namespaces you want to be able to see /in that specific file/.
(What can be confusing is that people often make the name of their library
the same as the name of the namespace in which they've placed the classes in
that library, by convention, but there's no strict requirement to do that).

For instance if you called the first library "otherlib.dll", you'd do this
when compiling the second assembly.

mcs -r:otherlib.dll secondfile.cs

Also, if your first class is still defined exactly like you had it in the
original post, then the 'using tst' I see in your second class there isn't
correct.  The original class had no "namespace tst { }" declaration around
the class, so it's automatically in the "global" namespace.  In that case,
"using tst" isn't just unnecessary, it's wrong -- the compiler will tell you
that there's no such namespace.

That is more info than you really need to solve the problem, which is this:
add the -r:otherlib.dll to your second command line, and remove the 'using
tst' from the second file (unless you actually did declare a tst namespace
in the first file that you just didn't include in the second one), and it
should work.


-----Original Message-----
From: Hans Poulsen [mailto:hap at solar.dk] 
Sent: Thursday, August 17, 2006 2:50 PM
To: Stephen Quattlebaum
Subject: RE: [Mono-winforms-list] Does not contain a static Main method su
itable for an entry point

Hi Stephen.

Sorry to desturbe you again. But I'm having trouble using the dll file in
another class.

using tst;

public class LineWriter
{ 
    public static void Main(string[] args) 
    {
	TST denne = new TST();
	denne.s = 3;
 	console.WriteLine(denne.s);       
    }
}

I have compilet tst with mcs -target:library tst.cs

But it seems to be unknown when I compile LineWriter.cs Is it because I need
to define from where to get it?

Med venlig hilsen / Best regards
Hans Poulsen

-----Original Message-----
From: Stephen Quattlebaum [mailto:stephen at covidimus.net]
Sent: 17. august 2006 15:56
To: Hans Poulsen
Cc: mono-winforms-list at lists.ximian.com
Subject: Re: [Mono-winforms-list] Does not contain a static Main method
suitable for an entry point

If by "intended to be an object" you mean "intended to be a reusable binary
component" (e.g., a .dll), then you need -target:library on the command
line.

mcs -target:library myfile.cs

Do 'man mcs' for more info.

On Tue, 15 Aug 2006, Hans Poulsen wrote:

> Hi everybody
>
> I keep getting this error every time I want to compile a class that is 
> intended to be an object. I'm running Mono on a windows XP machine, is 
> it
a
> missing compiler parameter, or can anybody tell me what courses this 
> problem?
>
> public static class TST
> {
> 	public static int num;
>
> 	public static void M()
> 	{
> 		num = 5;
> 	}
>
>
> }
>
>
> Best regards
> Rytme
>
>



More information about the Mono-winforms-list mailing list