Hi everyone, I'm trying to write a server application, but I'm having a bit of trouble. I keep getting this error
The name 'srvr' does not exist in the current context
I'm pretty sure I know what the problem is, but I don't know how to fix it. I have three classes so far: Program, notify_icon, and server. Program has the the main method which creates a server object and a notify icon object. Server does the work, notify_icon allows you to stop and start the server so notify_icon has to call server's start and stop methods. I think the problem is notify_icon's methods cannot access server's methods, but I'm not sure what to do I could move the code from notify_icon to Program, but I would like to keep it separate.
Let me know if you need me to try and explain something more.
Here is the main method from program
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Server srvr = new Server();
Notify_Icon icon = new Notify_Icon();
Application.Run();
}
this is the notify icon class
class Notify_Icon
{
public Notify_Icon () {
NotifyIcon icn = new NotifyIcon();
icn.Visible = true;
Stream strm = Assembly.GetExecutingAssembly().GetManifestResourceStream("WindowsFormsApplication1.Globe.ico");
icn.Icon = new Icon(strm);
ContextMenu menu = new ContextMenu();
menu.MenuItems.Add(0,
new MenuItem("Start", new System.EventHandler(srvr.Start)));
menu.MenuItems.Add(1,
new MenuItem("Stop", new System.EventHandler(srvr.Stop)));
icn.ContextMenu = menu;
}
Can someone please help me with this.