tags:

views:

914

answers:

4

Is is possible to create COM component and ActiveX controls in .Net (using c# language). I searched internet but i could`t get anything.

Thanks,
santhosh

A: 

I think you're looking for information on the "COM Callable Wrapper". Google for that, or a basic intro is here (I haven't read it): http://www.dnzone.com/ShowDetail.asp?NewsId=126

endian
A: 

Yes, it is possible, there is this article in CodeProject. A friend of mine tried it and had some trouble accessing the COM-object from his unmanaged app, though, so there are some pitfalls.

Treb
+2  A: 

Declare an interface and implement it with class.
If you have parameters/return values that are not OLE Automation compatible (custom structs, enums and so on), you might need to decorate them with the MarshalAs attribute.
Add the GUID attribute to both.
Add the COMVisible attribute to both. Alternatively, you can mark the assembly with it.
Use tlbexp to generate a type library for native clients.

Franci Penov
A: 

the .Net and COM interoperability Handbook by Alan Gordon ISBN 0-13-046130-X is an essential resource if you're doing a lot of interop stuff

Sneaky
He's going the other way - accessing .NET via COM.
endian