T
Tressa
Sorry to be such a novice about this but..... I have a windows service. It
contains two separate files. Both have the same namespace name.
I need to pass "bDisplay" into the other file. I am getting several errors
and not sure why or how to solve them does anyone have any help?
How do I access the other file?
ServerSocket.cs *This is where the main server start is so the" private bool
m_bIsDisplayed = false;" had to go here so it didn't reset every time.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Runtime.InteropServices;
using System.Net.Sockets;
using System.IO;
using System.Net;
using Listener;
using System.Threading;
namespace Listener
{
private bool m_bIsDisplayed = false;
public bool GetIsDisplayed()
{
return m_bIsDisplayed();
}
public void SetIsDisplayed(bool bDisplay)
{
m_bIsDisplayed = bDisplay;
}
}
SocketListner.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Runtime.InteropServices;
using System.Net.Sockets;
using System.Threading;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Web;
using System.Windows.Forms;
using Listener;
namespace Listener
{
private void MsgBxDisplayed(Byte [] byteBuffer, int size)
{
string sData = Encoding.ASCII.GetString(byteBuffer,0, size);
try
{
if (m_bIsDisplayed == true)
///Need pass variable here of TRUE or FALSE so it doesn't
continue with the default everytime.
{
System.Diagnostics.EventLog.WriteEntry(this.ToString(),sData);
}
else if (m_bIsDisplayed == false)
{
m_bIsDisplayed = true;
System.Diagnostics.EventLog.WriteEntry(this.ToString(),sData);
DialogResult result = MessageBox.Show("Failure", "WARNING!!",
MessageBoxButtons.OK,
MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1,
MessageBoxOptions.ServiceNotification);
if(result == DialogResult.OK)
{
// Closes the parent form.
//this.Close();
m_bIsDisplayed = false;
}
}
}
catch (Exception e)
{
System.Diagnostics.EventLog.WriteEntry(this.ToString(),
"invalid IsDisplayed" + e.Message);
}
}
errors:
error CS0118: 'Listener.ServerSocket.m_bIsDisplayed' denotes a 'field' where
a 'method' was expected
error CS0103: The name 'm_bIsDisplayed' does not exist in the class or
namespace 'Listener.SocketListener'
error CS0103: The name 'm_bIsDisplayed' does not exist in the class or
namespace 'Listener.SocketListener'
error CS0103: The name 'm_bIsDisplayed' does not exist in the class or
namespace 'Listener.SocketListener'
error CS0103: The name 'm_bIsDisplayed' does not exist in the class or
namespace 'Listener.SocketListener'
error CS0103: The name 'm_bIsDisplayed' does not exist in the class or
namespace 'Listener.SocketListener'
contains two separate files. Both have the same namespace name.
I need to pass "bDisplay" into the other file. I am getting several errors
and not sure why or how to solve them does anyone have any help?
How do I access the other file?
ServerSocket.cs *This is where the main server start is so the" private bool
m_bIsDisplayed = false;" had to go here so it didn't reset every time.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Runtime.InteropServices;
using System.Net.Sockets;
using System.IO;
using System.Net;
using Listener;
using System.Threading;
namespace Listener
{
private bool m_bIsDisplayed = false;
public bool GetIsDisplayed()
{
return m_bIsDisplayed();
}
public void SetIsDisplayed(bool bDisplay)
{
m_bIsDisplayed = bDisplay;
}
}
SocketListner.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Runtime.InteropServices;
using System.Net.Sockets;
using System.Threading;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Web;
using System.Windows.Forms;
using Listener;
namespace Listener
{
private void MsgBxDisplayed(Byte [] byteBuffer, int size)
{
string sData = Encoding.ASCII.GetString(byteBuffer,0, size);
try
{
if (m_bIsDisplayed == true)
///Need pass variable here of TRUE or FALSE so it doesn't
continue with the default everytime.
{
System.Diagnostics.EventLog.WriteEntry(this.ToString(),sData);
}
else if (m_bIsDisplayed == false)
{
m_bIsDisplayed = true;
System.Diagnostics.EventLog.WriteEntry(this.ToString(),sData);
DialogResult result = MessageBox.Show("Failure", "WARNING!!",
MessageBoxButtons.OK,
MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1,
MessageBoxOptions.ServiceNotification);
if(result == DialogResult.OK)
{
// Closes the parent form.
//this.Close();
m_bIsDisplayed = false;
}
}
}
catch (Exception e)
{
System.Diagnostics.EventLog.WriteEntry(this.ToString(),
"invalid IsDisplayed" + e.Message);
}
}
errors:
error CS0118: 'Listener.ServerSocket.m_bIsDisplayed' denotes a 'field' where
a 'method' was expected
error CS0103: The name 'm_bIsDisplayed' does not exist in the class or
namespace 'Listener.SocketListener'
error CS0103: The name 'm_bIsDisplayed' does not exist in the class or
namespace 'Listener.SocketListener'
error CS0103: The name 'm_bIsDisplayed' does not exist in the class or
namespace 'Listener.SocketListener'
error CS0103: The name 'm_bIsDisplayed' does not exist in the class or
namespace 'Listener.SocketListener'
error CS0103: The name 'm_bIsDisplayed' does not exist in the class or
namespace 'Listener.SocketListener'