小编Ang*_*igh的帖子

Windows服务启动和Exe

我目前正在开发一个包含WCF服务,Windows服务和WPF应用程序的项目.Windows服务与WCF通信,在某种情况下,必须启动WPF应用程序以便用户接收消息.(WCF位于远程服务器上,其余位于客户端上).我发布时遇到了一些障碍.我有服务将消息写入应用程序日志,以便我可以在某种程度上"调试".Windows服务运行以下代码没有问题.

C#代码,Windows服务:

WriteLog.WriteString("PostOffice.MessagesWaiting: Inside, starting up.", EventLogEntryType.Warning);
// Call the WPF Application
var messagingProcess = new Process();
var messageProcessStartInfo = new ProcessStartInfo(@"""C:\GoldenEyeMessages.exe""");
messageProcessStartInfo.CreateNoWindow = false;
messageProcessStartInfo.UseShellExecute = false;
messageProcessStartInfo.FileName = @"""C:\GoldenEyeMessages.exe""";
messageProcessStartInfo.WindowStyle = ProcessWindowStyle.Normal;
messageProcessStartInfo.Verb = "runas";

messageProcessStartInfo.RedirectStandardOutput = true;
messagingProcess.StartInfo = messageProcessStartInfo;
messagingProcess.Start();
StreamReader daStreamReaderMan = messagingProcess.StandardOutput;
string newString = daStreamReaderMan.ReadLine();

WriteLog.WriteString("PostOffice.MessagesWaiting: The Eagle has landed.", EventLogEntryType.Warning);
Run Code Online (Sandbox Code Playgroud)

WPF应用程序不在当前用户的会话中执行.相反,我得到一个弹出窗口来查看该消息.这是它的图片:

在此输入图像描述

选择"查看消息"选项后,它当然会切换到不同的会话,然后运行WPF应用程序.

我的问题是,如何让WPF应用程序在当前用户的会话或"活动"会话中启动?

c# wpf windows-services

4
推荐指数
1
解决办法
1889
查看次数

标签 统计

c# ×1

windows-services ×1

wpf ×1