-1

I want to reuse code from my Windows Forms App to my Window store app.
If I replace it and compile it, it gives compile time errors and I'm unable to find a way to fix it.

    private void Text_Click(object sender, RoutedEventArgs e)
    {
        var processinfo = new ProcessStartInfo();
        String arg ="\"C:\\Users\\chnpn\\Documents\\NetBeansProjects\\PartyDemo\\dist\\PartyDemo.jar\"";

        String path ="C:\\Users\\chnpn\\Documents\\NetBeansProjects\\PartyDemo\\newtest.wav";
        //processinfo.FileName = "C:\\FFMPEG\\bin\\ffmpeg.exe";
        //processinfo.Arguments = "-i 360.mp4 -vn -y 360_1.wma";
        processinfo.FileName = "C:\\ProgramData\\Oracle\\Java\\javapath\\java.exe";

        processinfo.Arguments = "-jar " + arg + " \"" + path + "\"";
        //processinfo.Arguments = "-jar " + arg;
        processinfo.RedirectStandardOutput = true;
        processinfo.RedirectStandardError = true;
        processinfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

        processinfo.UseShellExecute = false;
        processinfo.LoadUserProfile = true;
        processinfo.CreateNoWindow = true;
        //processinfo.EnvironmentVariables.Add("HOME", @"C:\Users\napatsawan\.ffmpeg");

        Process process = Process.Start(processinfo);
        process.OutputDataReceived += new DataReceivedEventHandler(setOutput);
        process.BeginOutputReadLine();
        process.Start();
        process.WaitForExit();
        // We may not have received all the events yet!
        Thread.Sleep(5000);
       // Console.ReadLine();
    }

It shows errors for the following

  • ProcessStartInfo
  • ProcessWindowStyle
  • Process
  • DataReceivedEventHandler(setOutput)
dhh
  • 4,289
  • 8
  • 42
  • 59

4 Answers4

0

A WPF .csproj file contains an addition property:

<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

Just put that in the first <PropertyGroup>...</PropertyGroup> section, it shouldn't matter where.

The meaning of {60dc8134-eba5-43b8-bcc9-bb4bc16c2548} is that this is a WPF project, and {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} indicates a C# project. You can learn more about project type guids from this SO Question

Community
  • 1
  • 1
DeshDeep Singh
  • 1,817
  • 2
  • 23
  • 43
0

The Windows Store Applications are not the same as Desktop applications! Namespaces, classes, methods that Desktop applications have.

If you are trying to run this code in a Windows Store app then i can tell you, that apps are sandboxes and they cannot use resources that are not theirs.

You cannot run commands on Windows Store Apps:

How can I run a command in windows store app?

But why you need the Windows Store app? The Windows 8/10 also use desktop applications - WPF, WF etc.

Community
  • 1
  • 1
Developer
  • 4,158
  • 5
  • 34
  • 66
0
  1. Not all .NET libraries are available in windows store applications.

  2. windows store does not run on forms, it runs on layouts.

  3. Many operations that occur synchronously in Winforms apps must be handled asynchronously in windows store applications.

As previously stated, windows store applications run in a "sandbox" meaning they are completely oblivious to everything else that is running. They are "Apps" not "Applications" your app should do everything it needs to do on its own.

0

The Desktop to UWP Bridge appears to be designed to handle this situation

https://developer.microsoft.com/en-us/windows/bridges/desktop

Blue Toque
  • 1,775
  • 13
  • 24