.dll Solidworks Add-in not registering in COM

Posted by Abhijit on Server Fault See other posts from Server Fault or by Abhijit
Published on 2014-06-03T08:48:09Z Indexed on 2014/06/03 9:27 UTC
Read the original article Hit count: 421

Filed under:
|
|
|

I am trying to register this .dll in COM as an Add-in to Solid Works software. The dll is building without any error or warnings.But the Add-in is not appearing in the Windows "Registry Editor" as should be the case.Kindly suggest me a solution. Thanks in advance. Below is my code:-

using System; using System.Collections; using System.Reflection; using System.Collections.Generic; using System.Linq; using System.Text; using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swcommands; using SolidWorks.Interop.swconst; using SolidWorks.Interop.swpublished; using SolidWorksTools; using SolidWorksTools.File; using System.Runtime.InteropServices; using System.Diagnostics;

namespace SWADDIN_Test { [ComVisible(true)] [Guid("C380F7A6-771A-41EE-807A-1689C8E97720")] [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] interface ISWIntegration { void DoSWIntegration(); }//end of interface Dummy ISWIntegration

[Guid("5EE80911-9567-4734-8E55-C347EA4635B5")] [ClassInterface(ClassInterfaceType.None)] [ProgId("SWADDIN_Test.SWIntegration")] [ComVisible(true)] public class SWIntegration : ISwAddin,ISWIntegration { public SldWorks mSWApplication; private int mSWCookie;

public SWIntegration() { mSWApplication = null; mSWCookie = 0; }//end of parameterless constructor

public void DoSWIntegration() { }//end of dummy method DoSWIntegration

public bool ConnectToSW(object ThisSW, int Cookie) { mSWApplication = (SldWorks)ThisSW; mSWCookie = Cookie; // Set-up add-in call back info bool result = mSWApplication.SetAddinCallbackInfo(0, this, Cookie); this.UISetup(); return true; }//end of method ConnectToSW()

public bool DisconnectFromSW() { return UITeardown(); }//end of method DisconnectFromSW()

public void UISetup() { }//end of method UISetup()

public bool UITeardown() { return true; }//end of method UITeardown()

[ComRegisterFunction()]//Attribute private static void ComRegister(Type t) { string keyPath = String.Format(@"SOFTWARE\SolidWorks\AddIns{0:b}", t.GUID); using (Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(keyPath)) { rk.SetValue(null, 1);// Load at startup rk.SetValue("Title", "Abhijit_SwAddin"); // Title rk.SetValue("Description", "All your pixels now belong to us"); // Description }//end of using statement }//end of method ComRegister()

[ComUnregisterFunction()]//Attribute private static void ComUnregister(Type t) { string keyPath = String.Format(@"SOFTWARE\SolidWorks\AddIns{0:b}", t.GUID); Microsoft.Win32.Registry.LocalMachine.DeleteSubKeyTree(keyPath); }//end of method ComUnregister()

}//end of class SWIntegration }//end of namespace SWADDIN_Test

© Server Fault or respective owner

Related posts about c#

Related posts about com