.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!
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
Get Affected Rows on Executenonquery
Regex Word Boundary Expressions
C# Linq Where Date Between 2 Dates
How to Determine If an Event Is Already Subscribed
How to Log a User Out When They Close Their Browser or Tab in ASP.NET MVC
How to Split an Ienumerable<String> into Groups of Ienumerable<String>
How to Define Multiple Names for Xmlelement Field
How to Put Text on Progressbar
Identifying Nhibernate Proxy Classes
How to Tell If My Process Is Running as Administrator
Wpf Equivalent to Textrenderer
How to Check If Ioexception Is Not-Enough-Disk-Space-Exception Type
How to Detect Which .Net Runtime Is Being Used (Ms VS. Mono)
C# Linq Intersect/Except with One Part of Object
How to Get the Subscribers of an Event
Create Object Instance of a Class Having Its Name in String Variable