Added filename null or empty check. Start now calls the SetProcessHandle and SetProcessId function so that events are setup correctly. Bumped package version to 1.0.3
This commit is contained in:
parent
c78e599659
commit
5877042755
@ -15,7 +15,7 @@
|
||||
<PackageTags>MontoyaTech;Process.Net</PackageTags>
|
||||
<AssemblyName>MontoyaTech.Process.Net</AssemblyName>
|
||||
<RootNamespace>MontoyaTech.Process.Net</RootNamespace>
|
||||
<Version>1.0.2</Version>
|
||||
<Version>1.0.3</Version>
|
||||
<Company>MontoyaTech</Company>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
|
@ -427,6 +427,9 @@ namespace MontoyaTech.Process.Net
|
||||
if (startInfo == null)
|
||||
throw new InvalidOperationException("Process.StartInfo cannot be null.");
|
||||
|
||||
if (string.IsNullOrEmpty(startInfo.FileName))
|
||||
throw new InvalidOperationException("FileName cannot be null or empty.");
|
||||
|
||||
var processType = process.GetType();
|
||||
|
||||
var commandLine = new StringBuilder();
|
||||
@ -538,10 +541,11 @@ namespace MontoyaTech.Process.Net
|
||||
childErrorHandle?.Dispose();
|
||||
}
|
||||
|
||||
//Unsafely setup the process info.
|
||||
processType.GetField("_processId", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).SetValue(process, (int)processInfo.dwProcessId);
|
||||
processType.GetField("_haveProcessId", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).SetValue(process, true);
|
||||
processType.GetField("_processHandle", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).SetValue(process, processHandle);
|
||||
//Invoke SetProcessHandle
|
||||
processType.GetMethod("SetProcessHandle", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke(process, new object[] { processHandle });
|
||||
|
||||
//Invoke SetProcessId
|
||||
processType.GetMethod("SetProcessId", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke(process, new object[] { (int)processInfo.dwProcessId });
|
||||
|
||||
//Set the standard input writer if needed
|
||||
if (startInfo.RedirectStandardInput)
|
||||
|
Loading…
x
Reference in New Issue
Block a user