.Net Core 2.0 Process.Start Throws "The Specified Executable Is Not a Valid Application for This Os Platform"

.Net Core 2.0 Process.Start throws The specified executable is not a valid application for this OS platform

You can also set the UseShellExecute property of ProcessStartInfo to true

var p = new Process();
p.StartInfo = new ProcessStartInfo(@"C:\Users\user2\Desktop\XXXX.reg")
{
UseShellExecute = true
};
p.Start();

Seems to be a change in .net Core, as documented here.

See also breaking changes.

The specified executable is not a valid application for this OS platform

this is the correct way to write your code

Process p = new Process();
p.StartInfo = new ProcessStartInfo()
{
CreateNoWindow = true,
Verb = "print",
FileName = "PDfReader.exe", //put the path to the pdf reading software e.g. Adobe Acrobat
Arguments = "PdfFile.pdf" // put the path of the pdf file you want to print
};
p.Start();

WPF Using .Net 3.1 - Process.Start Excel File Error: The specified executable is not a valid application for this OS platform.

Looking around further, it seems that in .Net Core the UseShellExecute value is defaulted to false. Manually setting it to true fixed the issue. Here is the blog article I used to discover this fix: https://jeremybytes.blogspot.com/2019/08/converting-net-framework-to-net-core.html

The specified executable is not a valid application for this OS platform mediatoolkit

I found the source code.

It works well!

Sample Image

Snippet:

using MediaToolkit;
using MediaToolkit.Model;
using System;
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
var inputFile = new MediaFile { Filename = @"C:\Users\Admin\source\repos\ConsoleApp2\ConsoleApp2\music\123.mp3" };
using (var engine = new Engine())
{
engine.GetMetadata(inputFile);
}
Console.WriteLine(inputFile.Metadata.Duration);
System.Console.ReadLine();
}
}
}

Change your file, it is likely that your file is not supported.

Win32Exception when opening a pdf file

You can open pdf in default web browser.

Use:

Process.Start("explorer", helpPath);

For Internet Explorer:

Process.Start("C:\Program Files\Internet Explorer\iexplore.exe", helpPath);

C# Execute Application Using Process.Start() as params to cmd and active RedirectStandardOutput

Looks like you're intending to start CMD and run a command, but your code just tries to run that command as an application.

Try something like this.

    var p = new Process();
p.StartInfo = new ProcessStartInfo(@"cmd.exe")
{
RedirectStandardOutput = true,
UseShellExecute = false,
Arguments = "/c C:\Users\hed-b\Desktop\PulserTester.appref-ms"
};
p.Start();
reportNumber = p.StandardOutput.ReadToEnd();
p.WaitForExit();

Using the blocking ReadToEnd will pause your thread while that code runs and makes it harder to capture error output also - Have a look at this answer for a demonstration of a non blocking solution that captures both standard data and standard err : ProcessInfo and RedirectStandardOutput



Related Topics



Leave a reply



Submit