I am trying to launch a .NET 8 console application from a .NET 4.8 application and capture the stdout to use that output in the .NET 4.8 application. This all works.
However, if .NET 8.0 is not installed when I launch the console application from a cmd prompt I get the following:
App: C:UsersgtownsendDesktopDistHSInstallPublisherHSInstallPublisher.exe
Architecture: x64
Framework: ‘Microsoft.NETCore.App’, version ‘8.0.0’ (x64)
.NET location: C:Program FilesdotnetThe following frameworks were found:
2.1.30 at [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
3.1.10 at [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
3.1.32 at [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
5.0.4 at [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
5.0.9 at [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
5.0.17 at [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
6.0.8 at [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
6.0.26 at [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
6.0.31 at [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
7.0.20 at [C:Program FilesdotnetsharedMicrosoft.NETCore.App]Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failedTo install missing framework, download:
https://aka.ms/dotnet-core-applaunch %5C>framework=Microsoft.NETCore.App&framework_version=8.0.0&arch=x64&rid=win10-x64
However, this text does not show up in stdout or stderror when calling the process nor does it throw an exception, it simply closes.
Following is a sample application:
using System;
using System.Diagnostics;
using System.Text;
internal class Program
{
static void Main(string[] args)
{
StringBuilder sb = new StringBuilder();
var process = new Process();
process.StartInfo.FileName = @"d:tempDotNet8ConsoleApp.exe";
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false; // Required for redirection
process.OutputDataReceived += (sender, e) => sb.Append(e.Data);
process.ErrorDataReceived += (sender, e) => sb.Append(e.Data);
process.Start();
process.BeginOutputReadLine();
process.WaitForExit();
Console.WriteLine(sb.ToString());
Console.ReadLine();
}
}
The output of the above program outputs a blank line.
Any ideas?
user25640474 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.