hiii私はWCFを初めて使用し、コンソールアプリケーションでコードを記述しました。私はこのようなサービスを作成しました
[ServiceContract]
public interface IHelloService
{
[OperationContract]
void SayHello(string msg);
}
関数を定義します
public class HelloService: IHelloService
{
public void SayHello(string msg)
{
Console.WriteLine("I rec message : " + msg);
}
}
メインプログラムファイルからサービスを開始しています
static void Main(string[] args)
{
Console.WriteLine("******* Service Console *******");
using(ServiceHost host = new ServiceHost(typeof(HelloWcfServiceLibrary.HelloService)))
{
host.AddServiceEndpoint(typeof(IHelloService), new NetTcpBinding(), "net.tcp://localhost:9000/HelloWcfService");
host.Open();
Console.Read();
}
}
クライアント側のコードは
static void Main(string[] args)
{
IHelloService proxy = ChannelFactory<IHelloService>.CreateChannel(new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:9000/HelloWcfService"));
string msg;
while (true)
{
msg = Console.ReadLine();
msg = proxy.SayHello(msg);
Console.WriteLine("Server returned " + msg);
}
}
正常に動作していますが、Windowsフォームアプリケーションで同じことを行い、受信したデータをrichtextboxに表示したいのですが、その方法がわかりません。誰か助けてください