Note that there are some explanatory texts on larger screens.

plurals
  1. POa little help instancing a wcf object, events don't work
    primarykey
    data
    text
    <p>Still struggling with the server side of my wcf application. :)</p> <p>As you can see from the code, I am trying to trigger an event whenever a client makes <em>StartConnection</em>. But somehow seems I can't instance the server object right, as it gives me this 3 error.</p> <p>Please suggest, what would be the right way to do that? Thanks! :)</p> <pre><code>namespace server2 { public partial class Form2 : Form { public Form2() { InitializeComponent(); myServer.eventHappened += new EventHandler(eventFunction); // 'server2.IfaceClient2Server' does not contain a definition for 'eventHappened' and no extension method 'eventHappened' accepting a first argument of type 'server2.IfaceClient2Server' could be found (are you missing a using directive or an assembly reference?) } IfaceClient2Server myServer = new ServerClass(); // The type or namespace name 'eventCaller' could not be found (are you missing a using directive or an assembly reference?) void eventFunction(object sender, EventArgs e) { label1.Text = myServer.clientName; // 'server2.IfaceClient2Server' does not contain a definition for 'clientName' and no extension method 'clientName' accepting a first argument of type 'server2.IfaceClient2Server' could be found (are you missing a using directive or an assembly reference?) } } class ServerClass : IfaceClient2Server { public event EventHandler eventHappened; //IfaceServer2Client callback = OperationContext.Current.GetCallbackChannel&lt;IfaceServer2Client&gt;(); public string clientName; public void StartConnection(string name) { clientName = name; eventHappened(this, new EventArgs()); MessageBox.Show(clientName + " has connected!"); } public void Message_Cleint2Server(string msg) { } public void Message2Client(string msg) { } } [ServiceContract(Namespace = "server", CallbackContract = typeof(IfaceServer2Client), SessionMode = SessionMode.Required)] public interface IfaceClient2Server ///// what comes from the client to the server. { [OperationContract(IsOneWay = true)] void StartConnection(string clientName); [OperationContract(IsOneWay = true)] void Message_Cleint2Server(string msg); } public interface IfaceServer2Client ///// what goes from the sertver, to the client. { [OperationContract(IsOneWay = true)] void AcceptConnection(); [OperationContract(IsOneWay = true)] void RejectConnection(); [OperationContract(IsOneWay = true)] void Message_Server2Client(string msg); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload