我是在应用文件件下引入类项目中的自定义类,但是输出时连应用的dll也输出了,有没办法,不输出应用的类,使程序正常运行,希望高手指点,谢谢。

解决方案 »

  1.   

    签名dll,布署到GAC中应该可以.
      

  2.   

    除了签名然后ngen.exe部署之外,那就是拷贝到本地了。
      

  3.   

    第一步
    用下面的命令创建一个新的随机密钥对并将其存储在 keyPair.snk 中
    sn命令是.Net裡面的
    sn -k keyPair.snk
    第二步
    右擊項目, 然後點屬性, 裡面有一個簽名的頁簽
    在這個面簽中點上<為程序集簽名>
    後下面的
    選擇強名稱密鑰文件
    選擇你剛才生成的keyPair.snk
    這樣你的項目,生成後就有簽名了第三步
    生成的DLL註冊到 GAC中就OK了
    注冊後還要在註冊表項中
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx]
    這個下面加一個鍵
    如 BB  
    然後  BB的值就是你放DLL的路徑
    你可以進到這個注冊項,應該已經有很多,你看一下就知道了如果後面的看不懂, 你就只看前面三步也就行了
    也可以直接加我Google Talk: liuruxin2002 或是MSN: [email protected] 聯繫這些動作也可以在安裝項目中直接完成關鍵代碼如下
    namespace RegistryDLL
    {
        [RunInstaller(true)]
        public partial class InstallerGac : Installer
        {
            public InstallerGac()
            {
                InitializeComponent();
            }        public override void Commit(System.Collections.IDictionary savedState)
            {
                string dllPath = "";
                string assemblyFullPath = Assembly.GetExecutingAssembly().Location;            string FullPath = Path.GetDirectoryName(assemblyFullPath);
                Publish publisher = new Publish();
                dllPath = FullPath + "\\LRSubSystem\\AP\\LRComponent.APServer.dll";
                publisher.GacInstall(dllPath);
                dllPath = FullPath + "\\LRSubSystem\\AP\\LRComponent.DBManage.dll";
                publisher.GacInstall(dllPath);
                dllPath = FullPath + "\\LRSubSystem\\LRComponent.StandardLibaray.dll";
                publisher.GacInstall(dllPath);
                dllPath = FullPath + "\\LRSubSystem\\LRComponent.UIControls.dll";
                publisher.GacInstall(dllPath);            RegistryKey MyKey = Registry.LocalMachine;
                RegistryKey SubKey = MyKey.OpenSubKey("SOFTWARE", true);
                SubKey = SubKey.OpenSubKey("Microsoft", true);
                SubKey = SubKey.CreateSubKey(".NETFramework");
                SubKey = SubKey.CreateSubKey("v2.0.50727");
                SubKey = SubKey.CreateSubKey("AssemblyFoldersEx");
                RegistryKey wSubKey = SubKey.CreateSubKey("LRToolCase");
                wSubKey.SetValue("", FullPath + "\\LRSubSystem\\");
                wSubKey.Close();
                wSubKey = SubKey.CreateSubKey("LRToolCaseAP");
                wSubKey.SetValue("", FullPath + "\\LRSubSystem\\AP\\");
                wSubKey.Close();
                SubKey.Close();
                MyKey.Close();
                base.Commit(savedState);
            }
            public override void Uninstall(System.Collections.IDictionary savedState)
            {
                string dllPath = "";
                string assemblyFullPath = Assembly.GetExecutingAssembly().Location;
                string FullPath = Path.GetDirectoryName(assemblyFullPath);
                Publish publisher = new Publish();
                //反注冊組件到 GAC              
                dllPath = FullPath + "\\LRSubSystem\\AP\\LRComponent.APServer.dll";
                publisher.GacRemove(dllPath);
                dllPath = FullPath + "\\LRSubSystem\\AP\\LRComponent.DBManage.dll";
                publisher.GacRemove(dllPath);
                dllPath = FullPath + "\\LRSubSystem\\LRComponent.StandardLibaray.dll";
                publisher.GacRemove(dllPath);
                dllPath = FullPath + "\\LRSubSystem\\LRComponent.UIControls.dll";
                publisher.GacRemove(dllPath);            RegistryKey MyKey = Registry.LocalMachine;
                RegistryKey SubKey = MyKey.OpenSubKey("SOFTWARE", true);
                try
                {
                    SubKey = SubKey.OpenSubKey("Microsoft", true);
                    SubKey = SubKey.OpenSubKey(".NETFramework", true);
                    SubKey = SubKey.OpenSubKey("v2.0.50727", true);
                    SubKey = SubKey.OpenSubKey("AssemblyFoldersEx", true);
                    SubKey.DeleteSubKey("LRToolCase");
                    SubKey.DeleteSubKey("LRToolCaseAP");
                    SubKey.Close();
                    MyKey.Close();
                }
                catch
                {
                    SubKey.Close();
                    MyKey.Close();
                }
                base.Uninstall(savedState);
            }
        }
    }