我发现需要从c#程序内启动WPF应用程序。我写了一个名为eBrowse的简单WPF浏览器作为练习。然后,我被要求将它添加到已经在使用的c#程序中。想要C#程序启动WPF应用程序
我试过System.Diagnostics.Process.Start(@"C:\eBrowse");
但它没有奏效。
这是一个网站上找到另一种可能性:
myProcess.StartInfo.UseShellExecute = true;
// You can start any process, HelloWorld is a do-nothing example.
//myProcess.StartInfo.FileName = "C:\\HelloWorld.exe";
myProcess.StartInfo.FileName = @"C:\eBrowse";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
// This code assumes the process you are starting will terminate itself.
// Given that is is started without a window so you cannot terminate it
// on the desktop, it must terminate itself or you can do it programmatically
// from this application using the Kill method.
我想知道,如果它可能无法启动从C#中的WPF应用程序。任何想法都会很棒。
谢谢大家的建议!不幸的是,WPF应用程序没有.exe,我认为这就是为什么我有这样的麻烦。我已经检查了多次,但没有办法从WPF获取.exe。 – 2011-03-10 14:02:38
你用什么来制作exe文件?我使用visual studio 2010,我的WPF应用程序有一个.exe。 – clamchoda 2011-03-10 14:58:10
你确定你有设置窗口来显示已知的文件扩展名吗? 在Windows资源管理器中,转至工具 - >文件夹选项 - >查看选项卡 - >确保“隐藏已知文件类型的扩展名”未选中。 – clamchoda 2011-03-10 15:00:25