RE: System.Windows.Forms question

"Oscar Papel" <[email protected]> Tue, 03 May 2005 05:01:08 +0000
Newsgroups gmane.comp.gnu.dotgnu.developer
Message-ID <[email protected]>
>I get this error:
>
>Ducks-Computer:~ duck$ cscc -o example.exe example.cs
>example.cs:8: `MessageBox' is not declared in the current scope
>example.cs:8: called object is not a method or delegate

MessageBox is not declared because you didn't provide the compiler with the 
reference to the assembly where it is located.

You are confusing namespaces with assemblies.
this is a common beginners problem.

The line "using System.Windows.Forms" specifies that this class references 
classes from this namespace.  Without this line, you would need to type:

System.Windows.Forms.MessageBox.Show(" ... ")

so the using line allows you a shorthand way of using classes outside your 
own namespace.

you need to use the following compiler command:

cscc example.cs -o example.exe -r System.Windows.Forms.dll

This provides the compiler with the assembly that holds the implementation 
of the System.Windows.Forms namespace.

It's confusing because, in this case, the namespace and the assembly have 
the same name.
It's even more confusing because Microsoft's compiler bends the rules and 
allows you to "forget" the reference.

Finally, the implementation of System.Windows.Forms.dll is incomplete at 
this time and there are GUI issues with the Mac version of the pnet platform 
so, for the time being, you will not be able to use the Mac and pnet to do 
what you want.

Hope this helps,

Oscar