I have a main application that uses a separate "Package Installer" application to update itself when a newer version is available. This update would include the main application, all DLL dependencies, plus the Package Installer itself. The process works like this:
Step 5 always fails due to the Package Installer being unable to overwrite files that are in use. The files are DLLs that the Package Installer itself has loaded from the app folder. These are DLLs that have no direct or indirect references to the Package Installer.
I have verified (using Windows Resource Monitor) that it is the Package Installer (and only that EXE) that has loaded the DLLs from the app folder. I have also double-checked that there are no references from the Package Installer project to these DLLs, either directly or through another DLL. I have also verified that the Package Installer loads the DLLs that it is dependant on (the 3 mentioned above) from the temp folder.
Finally, I have tried copying the entire application (every EXE & DLL) into the temp folder before running the Package Installer, but even then there is still some DLL that it loads from the app folder (not the ones mentioned above this time, but 3rd party DLLs).
What is going on and what can I do to suppress the loading of the extra DLLs?
答案 0 :(得分:1)
查看ProcessStartInfo.WorkingDirectory的MSDN文档。它注意到When UseShellExecute is true, the working directory of the application that starts the executable is also the working directory of the executable.
ProcessStartInfo startInfo = new ProcessStartInfo("c:\\path\\to\\filename.exe");
startInfo.UseShellExecute = false;
Process.Start(startInfo);
如果这不起作用,请尝试startInfo.WorkingDirectory = "c:\\path\\to";