Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Winforms nGen EXE+;DLL通过安装和部署项目_Winforms_C# 4.0_Setup Deployment_Ngen - Fatal编程技术网

Winforms nGen EXE+;DLL通过安装和部署项目

Winforms nGen EXE+;DLL通过安装和部署项目,winforms,c#-4.0,setup-deployment,ngen,Winforms,C# 4.0,Setup Deployment,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.De

我有以下代码,应将我的主应用程序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进行加密,还要对所有引用的DLL(我的整个解决方案)进行加密

假设我的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.getReferencedAssemblys()查找这些程序集。您只需使用Assembly.load/From()处理自己加载的程序集。查看/execonfig选项如果在.exe.config文件中有异常绑定规则,ngen.exe也需要知道这些规则,以便找到正确的程序集


其他方法有和。

这是自动的,ngen.exe通过Assembly.getReferencedAssemblys()查找这些程序集。您只需使用Assembly.load/From()处理自己加载的程序集。查看/execonfig选项如果在.exe.config文件中有异常绑定规则,ngen.exe也需要知道这些规则,以便找到正确的程序集

替代方法包括和