I have an odd situation you will find challenging and delight in finding possible reasons for its strange behavior.
I have some C Sharp code which is part of an ASP.NET project.
The C Sharp code gathers information and then launches a command-line type process on the server. It does this by using the following C# objects:
ProcessStartInfo
Process
A ProcessStartInfo variable is declared and it is given the name if the executable to run as a member of its constructor. This string variable also includes the path to the executable.
ProcessStartInfo startInfo = new ProcessStartInfo(sDirExe);
Then it is given a string for its arguments.
startInfo.Arguments = sArguments;
Now, here is the problem I am facing. If I start the process in such a way where my code has to wait for a completion, it seems to work. Like this:
Process p = Process.Start(startInfo);
p.WaitForExit();
It seems to work. The problem is that it is a very lenghty process I am starting and it takes literally hours to complete. I suspect that the IIS will time out before the process is done. But even if this is not the case, it is not a good to keep the user looking at a web page while the process is running.
But, on the other hand, I have tried to make the process run seperately from the C# code and this has not worked out well. Like this:
Process.Start(startInfo);
This, on the other hand, causes the program to throw an exception right away.
System.TypeInitializationException was unhandled
Message: The type initializer for 'Microsoft.DistributedAutomation.CommandLine.ConsoleApp' threw an exception.
WWYD?