private static void InjectAssemblyWithExternalFileNeeded() { var assemblyFile = Path.GetFullPath(Path.Combine("..", "..", "..", "WindowsFormHelloWorld", "bin", "Debug", "WindowsFormHelloWorld.exe")); var assemblyExecute = Assembly.LoadFile(assemblyFile); var assemblyDir = Path.GetDirectoryName(assemblyExecute.Location); Directory.SetCurrentDirectory(assemblyDir); var procInfo = new ProcessStartInfo(assemblyExecute.Location) { WorkingDirectory = assemblyDir }; var proc = Process.Start(procInfo); Thread.Sleep(1000); var injector = new Injector(proc.Id, typeof(AssemblyWithFileResourceNeeded.Main).Assembly); injector.AddFile("my_file.txt", Encoding.ASCII.GetBytes("External file content")); var injectionResult = injector.Inject(); proc.Kill(); Contract.Assert(injectionResult == InjectionResult.Success); Console.WriteLine("Injection successful"); }