If you managed to develop a self-hosting WCF functionality, nothing really changes if you want a service part be a
System.Windows.Forms
application. WCF would have no value if it was interlaced with certain types of UI and anything else not related to communication technology.
With you service contract it looks like you want to show the string supplied by a client in the
RichTextBox
which is on the service side.
Just re-implement your contract method.
For example, assuming you have a form:
using System.Windows.Forms;
public partial class MyForm : Form {
RichTextBox MyRichTextBox = new RichTextBox();
}
Implement your service interface in this form. For example, add a separate file with another part of the partial declaration:
public partial class MyForm : IHelloService {
void IHelloService.SayHello(string msg) {
MyRichTextBox.Text = msg;
}
}
Pay attention: you don't have to repeat ": Form" and ": IHelloService" in the inheritance lists of both partial class declarations — it is not needed which is very convenient. Also, I made interface implementation non-public using explicit implementation syntax (where any access modifier is not allowed). This syntax is much better as nobody can call the method
IHelloService.SayHello
accidentally.
—SA