문제

I have two applications, both are in WPF. My first application is GIS and it is in .NET 4.0 and my other application in .NET 3.5. In my GIS application, I'm loading a GIS data layers with icons. My requirement is to open the exe, which is my second application (.net 3.5) in the selected icon position (means at icon lat and long).

I want to know how I can load second exe on the icon position. Any help really appreciated on this.

도움이 되었습니까?

해결책

If you are using Process.Start() to launch your second exe, then you can pass the icon position as command line arguments in this method like:

Process.Start(@"C:\MyWPFApplication.exe", "50 60");

here assuming MyWPFApplication.exe is your second app and 50,60 are the coordinates you want to launch it on.

Now in App.xaml of MyWPFApplication, remove the StartUpUri and in App.xaml.cs override OnStartup() method as below to create the main applicatin window and set its Left and Top before showing it:

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            MainWindow window = new MainWindow();
            if(e.Args.Length == 2)
            {
                window.Left = double.Parse(e.Args[0]);
                window.Top = double.Parse(e.Args[1]);
            }
            window.Show();

        }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top