0

I am brand new to C# and UWP's and also pretty much Visual Studio, and I have now spent hours scouring the web trying to figure out how to get a button to open Command Prompt. The ultimate goal is to use it to execute a separate bit of Python code I've written, but baby steps. The reason I am not pursuing direct execution of the Python script (which I'm just assuming is possible) is because it has some output I would like to pass back to my UWP. I understand I may be going about this all wrong, but I don't know what I don't know so I'm just doing the best I can.

So, after hours of trying, I'm starting to wonder if using the latest version of Visual Studio (2017 downloaded a few days ago) is my actual problem. All of the solutions I keep finding in forums don't seem to work and it has me wondering if there are some namespaces or assemblies or libraries or whatever (shows you how much I know) that have been removed. I am consistently seeing "Process.Start..." but Process does not exist even when I try to add the various references the great internet keeps telling me to create. That's where I'm getting suspicious. When I go to the Reference Manager, under Assemblies->Extensions there is no "System" that I'm being told to add. But at the same time, I see Visual Studio already added "using System;" to the top of my code (header? forgive me).

So, I am in an endless loop of searching the web and typing BS into Visual Studio. Please help me. I'm going crazy. I will include the extremely limited code I have for your amusement (it's 95% Visual Studio generated).

using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace Jarvis_UWP__C_Sharp_
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
        }

        private async void Fetch_Click(object sender, RoutedEventArgs e)
        {
            ContentDialog TestDialog = new ContentDialog
            {
                Title = "Test",
                Content = "Popup",
                CloseButtonText = "Ok"
            };
            await TestDialog.ShowAsync();

            Process.Start(....);
        }
    }
}
SunnyNonsense
  • 410
  • 3
  • 22
  • 2
    Yes, it's a dupe of that question. Also you can look here for a tutorial: https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part-1/ – Stefan Wick MSFT Oct 23 '18 at 07:13
  • Thanks a lot for your help. It hadn't occurred to me that a language might be limited depending on its application...at least that's what I'm pulling from that other question ("...System.Diagnostics.Process isn't supported in UWP."). The rest of it about how to actually get around the problem is over my head. I've since decided I don't need a UWP and will instead try a WPF. – SunnyNonsense Oct 25 '18 at 23:36
  • It's not the language that's limited. What's different per application type is the available API surface and capabilities. If your goal is to write a Windows desktop app that launches arbitrary external processes then WPF (or any other Win32 based application type) is a better choice over UWP. – Stefan Wick MSFT Oct 26 '18 at 01:16

0 Answers0