[Mono-devel-list] Expression denotes a `type' ,where a `variable, value, method group' error

Jonathan Pryor jonpryor at vt.edu
Tue Aug 3 07:40:00 EDT 2004

On Mon, 2004-08-02 at 03:39, Trent Mifsud wrote:
> The error message I am receiving is as follows
> [Task:File=/home/trent/MonoDevelopProjects/LanRevealCmdLine/Main.cs, 
> Line=10, Column=-1, Type=Error, Description=Expression denotes a `type' 
> where a `variable, value, method group' was expected(CS0119)


> I checked it under MS's .net (gasp!) and it does work.

> using System;
> using LANReveal;
> class MainClass
> {
>     public static void Main(string[] args)
>     {
>         LANReveal.Worker w = new LANReveal.Worker();
>         MainClass m = new MainClass();
>         w.completed += LANReveal.WorkCompleted(m.writeToCMDLine);   
> //this is line 10 - err line

The above line is line 10, or the following line?

>         w.DoWork(); // starts searching
>     }

Regardless, since LANReveal is a namespace, LANReveal.WorkCompleted must
be a type, probably a delegate (based on how you're using it).  If this
is the case, you're missing a "new" keyword:

	w.completed += new LANReveal.WorkCompleted (m.writeToCMDLine);

The only way to avoid the "new" keyword would be to use C# 2.0 features,
such as implicit method -> delegate conversions, in which case you could
use this:

	w.completed += m.writeToCMDLine;

I'm not sure why your code compiles on .NET.  Maybe it's a CSC bug?  Or
(more likely) my assumptions are wrong, and something else is to blame. 
(The primary assumption I made is that LANReveal is a namespace, but it
could also be a nested type within a namespace --
LANReval.LANReveal.WorkCompleted could then be a method.  But nesting a
type within an identically named namespace is just...weird.)

 - Jon

More information about the Mono-devel-list mailing list