Hi Everyone...
I am trying to register a .dll file in COM.But it is failing and warnings are coming:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(935,9): warning MSB3391: "c:\users\acd92078.myttl\documents\visual studio 2010\Projects\SWADDIN_Test\SWADDIN_Test\bin\Debug\SWADDIN_Test.dll" does not contain any types that can be unregistered for COM Interop.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3341,9): warning MSB3214: "c:\users\acd92078.myttl\documents\visual studio 2010\Projects\SWADDIN_Test\SWADDIN_Test\bin\Debug\SWADDIN_Test.dll" does not contain any types that can be registered for COM Interop.
I have tried all the suggestions that were given previously in one of the discussions on similar error on PC review.
This 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("6701cbb8-ee73-46ed-bbe5-8a80c9a0280b")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
interface ISWIntegration
{
void DoSWIntegration();
}//end of interface Dummy ISWIntegration
[Guid("6701cbb8-ee73-46ed-bbe5-8a80c9a0280b")]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("SWADDIN_Test.SWIntegration")]
[ComVisible(true)]
public class SWIntegration : ISwAddin, ISWIntegration
{
public SldWorks mSWApplication;
private int mSWCookie;
public SWIntegration()
{ }//end of parametereless 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's 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
Kindly suggest me a solution on this.
Thanks in advance.
-Abhijit