0

上記の例外がスローされるという問題があります。プロセス間通信用のコードでサーバーとクライアントを作成しました。

サーバーは次のようになります。

[ServiceContract]
public interface INotifyFullScreen
{
    [OperationContract]
    void NotifyAndonFullScreen();
}

public class NotifyFullScreen : INotifyFullScreen
{
    public void NotifyAndonFullScreen()
    {
        MainWindow.CurrentInstance.NotifyFullScreen();
    }
}

//...NotifyFullScreen() implemented in another class

using (
    var host = new ServiceHost(
    typeof(NotifyFullScreen), new[] { new Uri("net.pipe://localhost/NotifyFullScreen") }))
{
    host.AddServiceEndpoint(
        typeof(INotifyFullScreen), new NetNamedPipeBinding(), "NotifyFullScreen");

    host.Open();
    app = new App();
    app.Run();
    host.Close();
}

...クライアントは次のようになります。

[ServiceContract]
public interface INotifyFullScreen
{
    [OperationContract]
    void NotifyAndonFullScreen();
}

//..

var pipeFactory = new ChannelFactory<INotifyFullScreen>(new NetNamedPipeBinding(), new
    EndpointAddress("net.pipe://localhost/NotifyFullScreen"));
var notifyProxy = pipeFactory.CreateChannel();

try
{
    notifyProxy.NotifyAndonFullScreen();
    pipeFactory.Close();
}
catch (Exception ex)
{
    MessageBox.Show("Exception!");
    EventTrace.Default.LogException(ex);
}

クライアントで (notifyProxy で) メソッドを呼び出そうとするたびに、上記の例外が発生します。

私は何を間違っていますか?どんな助けでも大歓迎です。

マーク

4

0 に答える 0