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