Calling C# executable from perl script

I am trying to execute a C# 4.0 console application from a perl script and trying to capture the output of the application. The C# application is a multithreaded application but it is writing the output to the console using the normal Console.WriteLine() function.

To fetch the output I am using the `` method in perl as :

my @commands = `app.exe param1 param2`

But when I am running the script I am getting error:

Unhandled Exception: System.IO.IOException: The handle is invalid.

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.Console.SetCursorPosition(Int32 left, Int32 top)
   at Netapp.CmDownload.Processor.DownloadProcessor.Start(String[] args)
   at Netapp.CmDownload.CmDownload.Main(String[] args)

terminating the application.

Note: C# application is a 64bit app running on .Net Framework 4.0 I have tried running the script using active perl 64bit as well as 32 bit version with no effect.

Jon Skeet
people
quotationmark

The problem is that your application is trying to use the console in a relatively advanced way - setting the cursor position. In this case, you don't really have a console, you just have piped output... so there's no console handle, and SetCursorPosition is failing.

See if there's any command line option to turn off the advanced console handling. (If it's your own app, add one :)

people

See more on this question at Stackoverflow