all groups > c# > november 2006 >
You're in the

c#

group:

Q: Is there a C# equilent to vbs ComClass?



Q: Is there a C# equilent to vbs ComClass? Martin Arvidsson
11/30/2006 10:48:08 PM
c#: Hi!

I have done a couple of ComClasses in vb, and from now on i want to code
ComClasses in C#
is there an equilent of this in c#? If not how to proceed to get the same
functionallity to be able to expose the com class?

Regards
Martin

Re: Is there a C# equilent to vbs ComClass? Kev
12/1/2006 12:00:00 AM
Hello,

I think from what you are asking you want to use C# to create a component
that appears to be a COM object - usable with classic VB and Component
Services etc. Your explanation is a little vague...

If so you need to create a CCW (COM Callable Wrapper) for your class. This
allows .Net apps use it as a .Net object, and COM clients as a COM object.

The process is roughly:

1 - Create your class (DLL)
2 - Create an interface to it
3 - Add some COM specific attributes
4 - Mark your class as implementing the interface

Note there are some limitations eg: you can't expose C# public static
methods using an interface (something I spent the last few days working
around).

I'll let you mull over that for a while. If you are stuck post back and tell
us how far you got.

Cheers!


[quoted text, click to view]

AddThis Social Bookmark Button