[Mono-devel-list] Not sure why this won't compile

rus rus at forgecom.co.uk
Tue Aug 2 04:03:28 EDT 2005


you haven't got 
using System;
in FECdomain.cs


On Tue, 2005-08-02 at 00:04 +0100, Paul wrote:
> Hi,
> 
> I have two source files (below). If I compile them up with
> -r:System.Drawing and -r:System.Windows.Forms, I get an error about the
> first file on the line which has EventArgs in it. Am I wrong in thinking
> that if I compile both files at the same time that EventArgs in the
> first file should be resolved by -r:S.W.F?
> 
> // FECdomain.cs
> using System.Text.RegularExpressions;
> 
> delegate void StringSplitHandler(object src, SplitStringArgs args);
> 
> class SplitStringArgs : EventArgs
> {
>   private SplitStringArgs() {}
>   public SplitStringArgs(string[] strings)
>   {
>     this.strings = strings;
>   }
> 
>   string[] strings;
>   public string[] Strings
>   {
>     get { return strings; }
>     set { strings = value; }
>   }
> }
> 
> class DomainSplitter
> {
>   Regex re = new Regex("\\s");
>   string[] substrings;
> 
>   public event StringSplitHandler StringsSplit;
> 
>   public void SplitString(string inStr)
>   {
>     substrings = re.Split(inStr);
>     StringsSplit(this, new SplitStringArgs(substrings));
>   }
> }
> 
> //FECdomain2.cs
> using System;
> using System.Drawing;
> using System.Windows.Forms;
> 
> class FECdomain : Form
> {
>   TextBox tb = new TextBox();
>   Button b = new Button();
>   label[] labels;
>   DomainSplitter domainObject = new DomainSplitter();
> 
>   FECdomain()
>   {
>     tb.Location = new Point(10, 10);
>     tb.Text = "The quick brown fox";
>     b.Location = new Point(150, 10);
>     b.Text = "Split text";
> 
>     b.Click += new EventHandler(this.GUIEvent);
>     domainObject.StringsSplit += new
> StringSplitHandler(this.DomainEvent);
> 
>     this.Text = "Form-Event-Control";
>     this.Controls.Add(tb);
>     this.Controls.Add(b);
>   }
> 
>   void GUIEvent(object src, EventArgs args)
>   {
>     domainObject.SplitString(tb.Text);
>   }
> 
>   void DomainEvent(object src, SplitStringsArgs args)
>   {
>     string[] strings = args.Strings;
>     if (labels != null)
>     {
>       foreach(Label l in labels)
> 	this.Controls.Remove(l);
>     }
>     labels = new Label[strings.Length];
> 
>     int row = 40;
>     for (int i = 0; i < labels.Length; i++)
>     {
>       labels[i] = new Label();
>       labels[i].Text = strings[i];
>       labels[i].Location = new Point(100, row);
>       row += 20;
>     }
>     this.Controls.AddRange(labels);
>   }
> 
>   public static void Main()
>   {
>     Application.Run(new FECdomain());
>   }
> }
> 
> mcs FECdomain.cs FECdomain2.cs -r:System.Windows.Forms -r:System.Drawing
> FECdomain.cs(6) error CS0246: The type or namespace name `EventArgs'
> could not be found. Are you missing a using directive or an assembly
> reference?
> Compilation failed: 1 error(s), 0 warnings.
> 
> TTFN
> 
> Paul
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
-- 
                         ''~``
                        ( o o )
+------------------.oooO--(_)--Oooo.------------------+
| RUS at FORGECOM.CO.UK                         FORGECOM |
| RUS,               .oooO           WEB APPLICATIONS |
| WEB DEVELOPER      (   )   Oooo. WWW.FORGECOM.CO.UK |
+---------------------\ (----(   )--------------------+
                       \_)    ) /
                             (_/





More information about the Mono-devel-list mailing list