private void publishRealTimeService() { try { string message = string.Format("Publishing Real Time service {0}, version {1}", realTimeServiceName, version); Console.WriteLine(message); executeCode("kyphosisModel <- rxLogit(Kyphosis ~ Age, data = kyphosis)"); executeCode("realTimeModel <- rxSerializeModel(kyphosisModel)"); executeCode("writeBin(realTimeModel, 'kyphosisService.bin')"); realTimeServiceName = "kyphosisService" + DateTime.Now.Ticks; Stream model = mrsServer.GetSessionFile(sessionId, "kyphosisService.bin"); string realTimeServiceFile = realTimeServiceName + ".bin"; using (var stream = new FileStream(realTimeServiceFile, FileMode.Create, FileAccess.Write)) { model.CopyTo(stream); } Func <Stream> modelStream = () => File.OpenRead(realTimeServiceFile); var response = mrsServer.PublishRealtimeWebServiceByNameVersion(realTimeServiceName, version, modelStream(), null, realTimeServiceName); try { // Delete file after publishing, as we no longer use it. File.Delete(realTimeServiceFile); } catch { // do nothing } realTimeServiceCreated = true; } catch (Exception e) { string message = string.Format("Publish Real Time service {0}, version {1} failed ", realTimeServiceName, version); throw new Exception(message + e.Message); } }