Skip to content
Discussion options

You must be logged in to vote

The issue happens because calling the static JsonRpc.Attach<T>(stream) twice creates two separate JsonRpc instances competing over the same stream.

The correct way to use multiple proxies over a single stream is to create one JsonRpc instance first, attach your interfaces, and then call StartListening():

var namedPipeClientStream = NamedPipeFactory.CreateNamedPipeClient(autoConnect: true);

// 1. Create a single JsonRpc connection
var jsonRpc = new JsonRpc(namedPipeClientStream);

// 2. Attach multiple proxies to the same connection
var proxyA = jsonRpc.Attach<IInterfaceA>();
var proxyB = jsonRpc.Attach<IInterfaceB>();

// 3. Start listening on the connection
jsonRpc.StartListening();

//…

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@ThaDaVos
Comment options

@AArnott
Comment options

@ThaDaVos
Comment options

@ThaDaVos
Comment options

Comment options

You must be logged in to vote
2 replies
@ThaDaVos
Comment options

@AArnott
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by AArnott
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants