質問

私はこのコードを持っています したほうがいい ngen私の主なアプリケーションexe:

using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration.Install;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;

namespace FileOnline.DesktopClient.Setup.Support {
    [RunInstaller(true)]
    public partial class CustomNGen : Installer {

        public override void Install(IDictionary stateSaver) {
            base.Install(stateSaver);
            ExecuteNGen("install", true);
        }

        public override void Uninstall(IDictionary savedState) {
            base.Uninstall(savedState);
            //CleanUpShortcuts();
            ExecuteNGen("uninstall", false);
        }

        private void ExecuteNGen(string cmd, bool validate) {
            var ngenStr = Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), "ngen");
            var assemblyPath = Context.Parameters["assemblypath"];

            using (var process = new Process {
                StartInfo = {
                    FileName = ngenStr,
                    Arguments = string.Format(@"{0} ""{1}""", cmd, assemblyPath),
                    CreateNoWindow = true,
                    UseShellExecute = false
                }
            }) {
                process.Start();
                process.WaitForExit();

                if (validate && process.ExitCode != 0)
                    throw new Exception(String.Format("Ngen exit code: {0}", process.ExitCode));
            }
        }

    }

}

私が必要とするのは、exeがngen'dだけでなく、参照されているすべてのdll(私のソリューション全体)もngen'dを取得することです

私のexeプロジェクトが呼ばれているとします:

FileOnline.DesktopClient

そしてそれはこれらに依存します:

FileOnline.DesktopClient.BaseControls
FileOnline.DesktopClient.BaseForms
FileOnline.DesktopClient.Utilities
FileOnline.DesktopClient.Dialogboxes
FileOnline.DesktopClient.HelpingExtension
FileOnline.DesktopClient.*More stuff*

ソリューション内の唯一の展開プロジェクトを使用して、これらをどのように確認できますか?

ありがとう。

役に立ちましたか?

解決

自動で、ngen.exeは、assembly.getRecreancedEdasemblies()を介してそれらのアセンブリを見つけます。 assembly.load/from()で自分でロードするアセンブリの世話をする必要があります。 /execonfigオプションを確認する.exe.configファイルに異常なバインディングルールがある場合は、ngen.exeも適切なアセンブリを見つけることができるようにする必要があります。

代替方法は次のとおりです ここここ.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top