2

初めてシャドウコピーを試しています。私は次のコードを持っています:

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がこの一時ディレクトリにコピーされていないため、アプリが爆発します。

私は何が欠けていますか?それらすべてを一時ディレクトリにもコピーするにはどうすればよいですか?

4

1 に答える 1

1

アプリには実質的に同じコードがあり、うまく機能します。

唯一の違いは、私たちの主な方法もで装飾されていることです

[LoaderOptimization(LoaderOptimization.MultiDomain)]

あなたはそれが違いを生むかどうか見るためにそれを試みるかもしれません。

于 2011-12-14T20:54:12.193 に答える