开发者

Want C# program to launch a WPF app

I've found a need to launch a WPF application from inside a c# program. I had written a simple WPF browser called eBrowse as an exercise for me. Then, I was requested to add it to a c# program that is already in use.

I tried System.Diagnostics.Process.Start(@"C:\eBrowse"); but it didn't work.

Another possibility that was found on a website:

myProcess.StartInfo.UseShellExecute = true;
// You can start any process, HelloWorld is a do-nothing example.
//myProcess.StartInfo.FileName = "C:\\HelloWorld.exe";
myProcess.Start开发者_StackOverflow中文版Info.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.

I am wondering if it may not be possible to launch a WPF app from c#. Any ideas would be great.


I think you are not specifying your EXE name. Try following:

myProcess.StartInfo.FileName = @"C:\eBrowse\yourEXeName.exe"; 


using System.Diagnostics;

Process myProc;
myProc = Process.Start("calc.exe");

Compiled and run on my system with visual studio 2008/10.

Just swap calc.exe with the full path to your exe.


remember to add the .exe extension. CreateNoWindow should be false.


Will this work for you? Winforms/WPF interoperability

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜