【SolidEdge AddIn 笔记】 Installer注册元件-写C#方式

此文章有参考国外网页http://leon.mvps.org/DotNet/RegasmInstaller.aspx
步骤
1.在Installer专案中,打开Custom Actions介面
http://img2.58codes.com/2024/20106503ZZqgCQALlv.jpg
2.在Install右键,选择加入自订动作
http://img2.58codes.com/2024/20106503Ftvuf6p2oY.jpg
3.Application Folder双点进入,选择自己的SolidEdge AddIn元件
http://img2.58codes.com/2024/20106503j6TI4kE6PL.jpg
4.在commit目录重複第3项动作
http://img2.58codes.com/2024/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.测试专案安装是否成功


关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章