iT邦幫忙

1

【SolidEdge AddIn 筆記】 Installer註冊元件-寫C#方式

2018-08-19 23:25:072218 瀏覽

此文章有參考國外網頁http://leon.mvps.org/DotNet/RegasmInstaller.aspx
步驟
1.在Installer專案中,打開Custom Actions介面
https://ithelp.ithome.com.tw/upload/images/20180819/20106503ZZqgCQALlv.jpg
2.在Install右鍵,選擇加入自訂動作
https://ithelp.ithome.com.tw/upload/images/20180819/20106503Ftvuf6p2oY.jpg
3.Application Folder雙點進入,選擇自己的SolidEdge AddIn元件
https://ithelp.ithome.com.tw/upload/images/20180819/20106503j6TI4kE6PL.jpg
4.在commit目錄重複第3項動作
https://ithelp.ithome.com.tw/upload/images/20180819/20106503IwCnngVI6Q.jpg
5.在AddIn元件加入以下程式碼,
需要注意執行的Framework是x86、x64版本,如果SolidEdge是支援x64,則安裝外掛要以x64的
regasm.exe安裝

   [RunInstaller(true)]
        public partial class RegisterDll : Installer
        {
            [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
            public override void Commit(System.Collections.IDictionary savedState)
            {
                base.Commit(savedState);

                // Get the location of regasm
                //string regasmPath = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() + @"regasm.exe";
                //x64
                 string regasmPath = @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe";
                // Get the location of our DLL
                string componentPath = typeof(RegisterDll).Assembly.Location;
                // Execute regasm
                System.Diagnostics.Process.Start(regasmPath, "/codebase \"" + componentPath + "\"");
            }

            [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
            public override void Install(System.Collections.IDictionary stateSaver)
            {
                base.Install(stateSaver);
            }
        }

6.測試專案安裝是否成功


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言