none
How to: Write an ActiveX object in C#?

Answers

All replies

  • I dont think you can build ActiveX controls in C# since ActiveX is based on COM. What you can do is build it in VC++ or VisualBasic 6 and use it from your C# code.
    It would be good if you could give us more context on what you are trying to acheive.

    Saturday, May 20, 2006 11:56 PM
  • > I dont think you can build ActiveX controls in C# since ActiveX is based on COM.

    Sure you can.  A good starting point is http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconexposingnetframeworkcomponentstocom.asp

    Sunday, May 21, 2006 9:00 AM
  • That is not building ActiveX component in C#, but consuming an ActiveX component from C# through COM-.NET interoperability. The ActiveX component is still built using a COM aware language like VC++ or VisualBasic 6.  
    Sunday, May 21, 2006 5:27 PM
  • > That is not building ActiveX component in C#...
    Yes it is.  The link is to the article "Exposing .NET Framework Components to COM", which describes how to build a component using .NET managed code and consume it from an unmanaged component.  The .NET component is exposed via a COM-Callable Wrapper (CCW)

    > consuming an ActiveX component from C# through COM-.NET interoperability
    This is also possible of course.  In this case .NET clients call unmanaged COM components via a runtime callable wrapper (RCW).  There is a different article that describes this: http://msdn.microsoft.com/library/en-us/cpguide/html/cpconexposingcomcomponentstonetframework.asp

     

     

     

    • Proposed as answer by MagnetPower Thursday, August 27, 2009 7:33 AM
    Sunday, May 21, 2006 8:01 PM
  • Consuming a .NET component from COM is not the same as building an ActiveX component in C#. It is just like saying using COM components in .NET applications is same as building a managed component using COM.
    Monday, May 22, 2006 4:54 AM
  • This example shows how to do it: http://www.codeproject.com/cs/miscctrl/exposingdotnetcontrols.asp?df=100&forumid=2373&exp=0&select=1359005

    Monday, May 22, 2006 11:19 AM
  • It is possible to create unmanaged COM applications using C#. I have built many of these for legacy asp applications.
    Monday, May 22, 2006 1:52 PM
  • It is possible to create unmanaged COM applications using C#. I have built many of these for legacy asp applications.


    But is that a real COM application ? It should be a managed application consumed from ASP (or COM) through COM-.NET interoperability, isnt it ? It still requires .NET runtime to be installed on the machine, doesnt it ? If so it is still a managed application.

    Tuesday, May 23, 2006 12:37 AM
  • > But is that a real COM application ?
    Yes
    > It should be a managed application consumed from ASP (or COM) through COM-.NET interoperability, isnt it ?
    Yes
    > It still requires .NET runtime to be installed on the machine, doesnt it ?
    Yes
    > If so it is still a managed application.
    Yes

    This is just a matter of terminology.  The fact that it requires the .NET runtime doesn't make it any less a COM object than, say, a COM object written in VB6 (which needs the VB6 runtime).  COM doesn't care about the internal implementation or dependencies of a component.


     

    Tuesday, May 23, 2006 6:50 AM
  • That is correct.. You can call it managed or unmanaged (technically managed), although it is still a "real" COM application.

    I usually refer to my C# COM objects as "unmanaged C#". Not because they are, but because I created them primarily to work with unmanaged languages. I have never once used my C# COM objects in a .Net application.
    Tuesday, May 23, 2006 11:29 AM
  • Pradeep,

    Joe is correct, ur just arguing out of context that leans bit on the ignorance side...
    Thursday, August 27, 2009 7:34 AM
  • Hello

    The CSActiveX sample in Microsoft All-In-One Code Framework is a demonstrates an ActiveX control written in C# with step-to-step guide.
    If you do not need a control, you can check out the CSDllCOMServer sample which is an in-proc COM server, or the CSExeCOMServer sample which is out-of-proc.


    Regards,
    Jialiang Ge
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Saturday, March 13, 2010 1:36 PM
    • Edited by AmmatAllah Wednesday, December 28, 2011 9:22 AM
    Wednesday, December 28, 2011 9:21 AM