EDN Admin
Well-known member
Hi,
I am trying to spawn an in-house made console application from a Windows Service.
I am spawning the process as follows, but currently I get the following exception written to the Windows 7 event viewer:
Application: AspexFileXfeService.exe Framework Version: v4.0.30319 Description:
<br/>
The process was terminated due to an unhandled exception. Exception Info: <br/>
System.IO.IOException Stack: at System.IO.__Error.WinIOError(Int32, <br/>
System.String) at System.IO.FileStream.Init(System.String, System.IO.FileMode, <br/>
System.IO.FileAccess, Int32, Boolean, System.IO.FileShare, Int32, <br/>
System.IO.FileOptions, SECURITY_ATTRIBUTES, System.String, Boolean, Boolean) at <br/>
System.IO.FileStream..ctor(System.String, System.IO.FileMode, <br/>
System.IO.FileAccess, System.IO.FileShare, Int32, System.IO.FileOptions) at <br/>
System.IO.StreamWriter.CreateFile(System.String, Boolean) at <br/>
System.IO.StreamWriter..ctor(System.String, Boolean, System.Text.Encoding, <br/>
Int32) at System.IO.StreamWriter..ctor(System.String, Boolean) at <br/>
System.IO.File.AppendText(System.String) at <br/>
iStore3ServiceLib.LogFile.WriteEntryToLogFile(System.String) at <br/>
iStore3ServiceLib.iStore3Service.RunAFADataUploader(System.String, <br/>
System.String) at <br/>
iStore3ServiceLib.iStore3Service+<>c__DisplayClass3.<TransferFile>b__0()
<br/>
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object) at <br/>
System.Threading.ExecutionContext.runTryCode(System.Object) at <br/>
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode,
<br/>
CleanupCode, System.Object) at <br/>
System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, <br/>
System.Threading.ContextCallback, System.Object) at <br/>
System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, <br/>
System.Threading.ContextCallback, System.Object, Boolean) at <br/>
System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, <br/>
System.Threading.ContextCallback, System.Object) at <br/>
System.Threading.ThreadHelper.ThreadStart()
<pre class="prettyprint //some method of the service
Thread t = new Thread(delegate()
{
RunDataUploader(uploaderEXEPath, somePath);
});
t.Start();
//functio that spawns application
void RunDataUploader(string UploaderEXE, string RunPath)
{
string RunPath = @"""" + RunPath + @"""";
//Process.Start(@"C:tempDebugDataUploaderConsole.exe", RunPath);
using (System.Diagnostics.Process process = new System.Diagnostics.Process())
{
process.StartInfo = new System.Diagnostics.ProcessStartInfo(UploaderEXE);
process.StartInfo.Arguments = @"""" + RunPath + @"""";
process.StartInfo.CreateNoWindow = true;
process.StartInfo.ErrorDialog = false;
//process.StartInfo.RedirectStandardError = true;
//process.StartInfo.RedirectStandardInput = true;
//process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = true;
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;
process.Start();
}
}[/code]
Note I dont care what the exit code is from the process and I dont need to wait for the application to complete.
Any help here would be appreciated.
View the full article
I am trying to spawn an in-house made console application from a Windows Service.
I am spawning the process as follows, but currently I get the following exception written to the Windows 7 event viewer:
Application: AspexFileXfeService.exe Framework Version: v4.0.30319 Description:
<br/>
The process was terminated due to an unhandled exception. Exception Info: <br/>
System.IO.IOException Stack: at System.IO.__Error.WinIOError(Int32, <br/>
System.String) at System.IO.FileStream.Init(System.String, System.IO.FileMode, <br/>
System.IO.FileAccess, Int32, Boolean, System.IO.FileShare, Int32, <br/>
System.IO.FileOptions, SECURITY_ATTRIBUTES, System.String, Boolean, Boolean) at <br/>
System.IO.FileStream..ctor(System.String, System.IO.FileMode, <br/>
System.IO.FileAccess, System.IO.FileShare, Int32, System.IO.FileOptions) at <br/>
System.IO.StreamWriter.CreateFile(System.String, Boolean) at <br/>
System.IO.StreamWriter..ctor(System.String, Boolean, System.Text.Encoding, <br/>
Int32) at System.IO.StreamWriter..ctor(System.String, Boolean) at <br/>
System.IO.File.AppendText(System.String) at <br/>
iStore3ServiceLib.LogFile.WriteEntryToLogFile(System.String) at <br/>
iStore3ServiceLib.iStore3Service.RunAFADataUploader(System.String, <br/>
System.String) at <br/>
iStore3ServiceLib.iStore3Service+<>c__DisplayClass3.<TransferFile>b__0()
<br/>
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object) at <br/>
System.Threading.ExecutionContext.runTryCode(System.Object) at <br/>
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode,
<br/>
CleanupCode, System.Object) at <br/>
System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, <br/>
System.Threading.ContextCallback, System.Object) at <br/>
System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, <br/>
System.Threading.ContextCallback, System.Object, Boolean) at <br/>
System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, <br/>
System.Threading.ContextCallback, System.Object) at <br/>
System.Threading.ThreadHelper.ThreadStart()
<pre class="prettyprint //some method of the service
Thread t = new Thread(delegate()
{
RunDataUploader(uploaderEXEPath, somePath);
});
t.Start();
//functio that spawns application
void RunDataUploader(string UploaderEXE, string RunPath)
{
string RunPath = @"""" + RunPath + @"""";
//Process.Start(@"C:tempDebugDataUploaderConsole.exe", RunPath);
using (System.Diagnostics.Process process = new System.Diagnostics.Process())
{
process.StartInfo = new System.Diagnostics.ProcessStartInfo(UploaderEXE);
process.StartInfo.Arguments = @"""" + RunPath + @"""";
process.StartInfo.CreateNoWindow = true;
process.StartInfo.ErrorDialog = false;
//process.StartInfo.RedirectStandardError = true;
//process.StartInfo.RedirectStandardInput = true;
//process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = true;
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;
process.Start();
}
}[/code]
Note I dont care what the exit code is from the process and I dont need to wait for the application to complete.
Any help here would be appreciated.
View the full article