diff --git a/Process.Net/Process.Net.csproj b/Process.Net/Process.Net.csproj
index 2079958..b290994 100644
--- a/Process.Net/Process.Net.csproj
+++ b/Process.Net/Process.Net.csproj
@@ -15,7 +15,7 @@
MontoyaTech;Process.Net
MontoyaTech.Process.Net
MontoyaTech.Process.Net
- 1.0.2
+ 1.0.3
MontoyaTech
MIT
README.md
diff --git a/Process.Net/WinProcess.cs b/Process.Net/WinProcess.cs
index 1a00547..0e92352 100644
--- a/Process.Net/WinProcess.cs
+++ b/Process.Net/WinProcess.cs
@@ -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)