ComClass in C#
-
Hello Everybody, How can we create a class using ComClass Template. First of all, I am not able to add the reference of Microsoft.Build.Tasks.V3.5 since it is not being listed out in the Add Reference dialog. So I browsed this dll and added the reference. Still my problem is not solved. I am getting the following error. 'Microsoft.Build.Tasks.Deployment.ManifestUtilities.ComClass' is not an attribute class I am not sure. Here is my code,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Build.Tasks.Deployment.ManifestUtilities;namespace COMArray
{
[ComClass(ComClass2.ClassId, ComClass2.InterfaceId, ComClass2.EventsId)]public class ComClass2 { #region "COM GUIDs" // These GUIDs provide the COM identity for this class // and its COM interfaces. If you change them, existing // clients will no longer be able to access the class. public const string ClassId = "83a8275f-9282-4257-ba62-afab6ed03beb"; public const string InterfaceId = "e75a1569-f1aa-4bdc-8e39-ae5807ee5baa"; public const string EventsId = "f966bdd3-9c5b-4ad9-8714-bc17d28f7e3a"; #endregion // A creatable COM class must have a Public Sub New() // with no parameters, otherwise, the class will not be // registered in the COM registry and cannot be created // via CreateObject. public ComClass2() : base() { } private int \_test; public int test { get { return \_test; } set { \_test = value; } } }
[ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)]
public class ComClass1
{#region "COM GUIDs" // These GUIDs provide the COM identity for this class // and its COM interfaces. If you change them, existing // clients will no longer be able to access the class. public const string ClassId = "35cf06df-5ed3-431f-9780-1e30d8acb94c"; public const string InterfaceId = "04fcc0fb-da33-4750-bab1-86e3b6d0e300"; public const string EventsId = "e073bca9-3bc5-437a-8c77-a489086c6517"; #endregion // A creatable COM class must have a Public Sub New() // with no parameters, otherwise, the class will not be // registered in the COM registry and cannot be created // via CreateObject. public Com