Hi all,
I have a main Qt application, launching a C# app with QProcess.
I would like to communicate with the C# app using the QProcess tools, the standard channels.
Although the communication is working perfectly when I compile the C# app with .net framework 3.5, I am not receiving any data from the process when it is compiled with .net 4.0 or 4.5
I posted a thread on the msdn forums : https://social.msdn.microsoft.com/Fo...=csharpgeneral
I have made a minimal console example to replicate the issue:
#include <QCoreApplication>
#include <QProcess>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
// Path to the C# executable
QString program
= "D:/Documents/ConsoleApplication1/ConsoleApplication1/bin/Release/ConsoleApplication1.exe";
// Start child Process
process->setProgram(program);
// Execute lambda function whenever a message from the process is received
QObject::connect(process,
&QProcess
::readyReadStandardOutput,
[&](){ cout << process
->readAll
().
toStdString();
} );
process->start();
string text;
cin >> text;
process
->write
( QByteArray::fromStdString(text
) + "\r\n" );
return a.exec();
}
#include <QCoreApplication>
#include <QProcess>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
// Path to the C# executable
QString program = "D:/Documents/ConsoleApplication1/ConsoleApplication1/bin/Release/ConsoleApplication1.exe";
// Start child Process
QProcess * process = new QProcess();
process->setProgram(program);
// Execute lambda function whenever a message from the process is received
QObject::connect(process, &QProcess::readyReadStandardOutput, [&](){ cout << process->readAll().toStdString(); } );
process->start();
string text;
cin >> text;
process->write( QByteArray::fromStdString(text) + "\r\n" );
return a.exec();
}
To copy to clipboard, switch view to plain text mode
and a minimal C# example :
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string text;
while (true)
{
Console.WriteLine("0");
text = Console.ReadLine();
Console.WriteLine("1");
Console.WriteLine(text);
}
}
}
}
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string text;
while (true)
{
Console.WriteLine("0");
text = Console.ReadLine();
Console.WriteLine("1");
Console.WriteLine(text);
}
}
}
}
To copy to clipboard, switch view to plain text mode
I am using Qt 5.4.1 on windows 7, and compiling with msvc 2010 32 bits.
Thanks in advance for your help
Bookmarks