private void HandleRequest(Message message) { var payload = (IpcRequest)message.Payload; var type = GetType(payload.ContractName); using (var scope = _serviceProvider.CreateScope()) { try { if (scope.ServiceProvider.GetRequiredService <ICallContext>() is CallContext context) { context.CallerInfo = message.SenderInfo; } var instance = scope.ServiceProvider.GetRequiredService(type); var request = (IpcRequest)message.Payload; var response = Call(type, request.MethodName, request.Arguments, instance); _messageChannel.Broadcast(Message.CreateResponse(message.Id, _configuration.ClientInfo, message.SenderInfo, response)); } catch (Exception e) { _messageChannel.Broadcast(Message.CreateError(_configuration.ClientInfo, message.SenderInfo, message.Id, e, "Error occured handling request")); } } }