我在第一次嘗試Shadow Copy。我有以下代碼:AppDomain影子複製包含引用的程序集
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
var sApplicationDirectory = Application.StartupPath;
var sAppName = "propane";
AppDomainSetup oSetup = new AppDomainSetup();
string sApplicationFile = null;
// Use this to ensure that if the application is running when the user performs the update, that we don't run into file locking issues.
oSetup.ShadowCopyFiles = "true";
oSetup.ApplicationName = "MyApplication";
// Generate the name of the DLL we are going to launch
sApplicationFile = System.IO.Path.Combine(sApplicationDirectory, sAppName + ".exe");
oSetup.ApplicationBase = sApplicationDirectory;
oSetup.ConfigurationFile = sApplicationFile + ".config";
oSetup.LoaderOptimization = LoaderOptimization.MultiDomain;
// Launch the application
AppDomain oAppDomain = AppDomain.CreateDomain(sAppName, AppDomain.CurrentDomain.Evidence, oSetup);
oAppDomain.SetData("App", sAppName);
oAppDomain.ExecuteAssembly(sApplicationFile);
// When the launched application closes, close this application as well
Application.Exit();
//Application.EnableVisualStyles();
//Application.SetCompatibleTextRenderingDefault(false);
//Application.Run(new Form1());
}
}
可執行在到達臨時目錄就好及其運行,直到我達到一個被引用的DLL。我在整個項目中引用的14-16個dll不會被複制到這個臨時目錄,導致應用程序崩潰。
我錯過了什麼?我如何將它們都複製到臨時目錄中?
與sApplicationFile位於同一目錄中的所有依賴項是否都是? (不在子目錄中) –
是的,它們與可執行文件位於同一目錄中。 – ErocM