Click here to Skip to main content
15,921,179 members
Home / Discussions / COM
   

COM

 
GeneralRe: Start learning COM Pin
Fragging14-Mar-05 8:31
Fragging14-Mar-05 8:31 
Actually you can write COM in C#. It is a horrible implementation technology for COM. I have done this using a C# server and a C++ client.

In C# you declare an interface like this:

[Guid( "ert565645-EA16-4a8c-8CDD-434564565675" ),
InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface _<MyObjectName>
{
string InterfaceMethod1;
InterfaceMethod2
}

Your class then extends that interface:

[Guid( "3D655F63-118B-4e28-B1D5-30DD4AE77424" )]

public class <MyObjectName> : _<MyObjectName>
{

public string Method1()
{
return "Silly";
}

string InterfaceMethod1()
{
return Method1();
}


Stuff like that can work. It is difficult to work with and best advised to stay away from. When you return an object from a call in an interface you will run into problems that the interface does not know about the object and therefore making calls on that object becomes problematic. To deal with this problem you will have to add an attribute to the declaration of your Class. This Attribute [System.Runtime.InteropServices.ComVisible(true)] is added to the declaration of your class.

Please note that doing this flys in the face of everything that COM interactions stand for, but it does work. Also you will have to generate a hack header file to handle certain types used when the typelibrary is imported into your C++ code.

Regards

Ward

Frag
Try, Fail..Fail, Succeed
Tool Developer
Michigan, USA
GeneralWord document to stream Pin
jan larsen23-Feb-05 21:34
jan larsen23-Feb-05 21:34 
GeneralRe: Word document to stream Pin
vishalmore23-Feb-05 23:09
vishalmore23-Feb-05 23:09 
GeneralRe: Word document to stream Pin
jan larsen23-Feb-05 23:44
jan larsen23-Feb-05 23:44 
GeneralRe: Word document to stream Pin
vishalmore1-Mar-05 2:39
vishalmore1-Mar-05 2:39 
GeneralRe: Word document to stream Pin
jan larsen1-Mar-05 2:49
jan larsen1-Mar-05 2:49 
GeneralRe: Word document to stream Pin
jan larsen2-Mar-05 1:08
jan larsen2-Mar-05 1:08 
GeneralRe: Word document to stream Pin
Jörgen Sigvardsson26-Feb-05 8:08
Jörgen Sigvardsson26-Feb-05 8:08 
GeneralRe: Word document to stream Pin
jan larsen27-Feb-05 20:05
jan larsen27-Feb-05 20:05 
Generalextracting mail from yahoo using mozilla Pin
Spiritofamerica23-Feb-05 5:09
Spiritofamerica23-Feb-05 5:09 
GeneralC++ Client for a C# object Pin
Fragging22-Feb-05 9:14
Fragging22-Feb-05 9:14 
GeneralRe: C++ Client for a C# object Pin
Fragging28-Feb-05 3:08
Fragging28-Feb-05 3:08 
GeneralDifference b/e COM and ActiveX Pin
Muhammad Azam21-Feb-05 23:40
Muhammad Azam21-Feb-05 23:40 
GeneralRe: Difference b/e COM and ActiveX Pin
ThatsAlok22-Feb-05 6:08
ThatsAlok22-Feb-05 6:08 
GeneralRe: Difference b/e COM and ActiveX Pin
Muhammad Azam22-Feb-05 17:24
Muhammad Azam22-Feb-05 17:24 
GeneralRe: Difference b/e COM and ActiveX Pin
ThatsAlok22-Feb-05 18:44
ThatsAlok22-Feb-05 18:44 
GeneralRe: Difference b/e COM and ActiveX Pin
Muhammad Azam22-Feb-05 18:57
Muhammad Azam22-Feb-05 18:57 
QuestionWhat are the rules for changing a published COM interface? Pin
Sir Garence21-Feb-05 15:15
sussSir Garence21-Feb-05 15:15 
AnswerRe: What are the rules for changing a published COM interface? Pin
Christian Graus21-Feb-05 15:31
protectorChristian Graus21-Feb-05 15:31 
GeneralRe: What are the rules for changing a published COM interface? Pin
Sir Garence22-Feb-05 4:25
sussSir Garence22-Feb-05 4:25 
GeneralRe: What are the rules for changing a published COM interface? Pin
Christian Graus22-Feb-05 8:41
protectorChristian Graus22-Feb-05 8:41 
GeneralCOM with C# multi client model Pin
sokettepower20-Feb-05 23:50
sokettepower20-Feb-05 23:50 
GeneralRe: COM with C# multi client model Pin
vishalmore21-Feb-05 18:08
vishalmore21-Feb-05 18:08 
QuestionCan we set a global hook in a COM object? Pin
nadzzz20-Feb-05 7:24
nadzzz20-Feb-05 7:24 
AnswerRe: Can we set a global hook in a COM object? Pin
Jörgen Sigvardsson20-Feb-05 9:02
Jörgen Sigvardsson20-Feb-05 9:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.