Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. ? implement a COM Components method.

? implement a COM Components method.

Scheduled Pinned Locked Moved C#
csharpcomtutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lgatcodeproject
    wrote on last edited by
    #1

    Hi EveryOne, I am writing a windows application that Refers a COM component which exposes a single function called Connect(). I have referenced COM Component but I don't know how to call this function on a button click. In VB we create a variable and then set an instance of the class object to the varibale, finally browsing this variable with a dot operator would reveal the methods exposed by the class. How do we achieve the same in C#? I am new to C# so kindly excuse me if this is very basic and I am wasting your valuable time. Thanks. Regards, LG.

    lgatcodeproject

    S 1 Reply Last reply
    0
    • L lgatcodeproject

      Hi EveryOne, I am writing a windows application that Refers a COM component which exposes a single function called Connect(). I have referenced COM Component but I don't know how to call this function on a button click. In VB we create a variable and then set an instance of the class object to the varibale, finally browsing this variable with a dot operator would reveal the methods exposed by the class. How do we achieve the same in C#? I am new to C# so kindly excuse me if this is very basic and I am wasting your valuable time. Thanks. Regards, LG.

      lgatcodeproject

      S Offline
      S Offline
      Simon P Stevens
      wrote on last edited by
      #2

      lgatcodeproject wrote:

      In VB we create a variable and then set an instance of the class object to the varibale, finally browsing this variable with a dot operator would reveal the methods exposed by the class. How do we achieve the same in C#?

      The same works in C#. You use the New operator to create a new instance. MyClass myObject = new MyClass(); myObject.SomeMethod(); If you want to do something on a button click, you just find the handler for the click event for the button, and put the code in their. Post your code. Which bit are you having trouble with?

      Simon

      L 1 Reply Last reply
      0
      • S Simon P Stevens

        lgatcodeproject wrote:

        In VB we create a variable and then set an instance of the class object to the varibale, finally browsing this variable with a dot operator would reveal the methods exposed by the class. How do we achieve the same in C#?

        The same works in C#. You use the New operator to create a new instance. MyClass myObject = new MyClass(); myObject.SomeMethod(); If you want to do something on a button click, you just find the handler for the click event for the button, and put the code in their. Post your code. Which bit are you having trouble with?

        Simon

        L Offline
        L Offline
        lgatcodeproject
        wrote on last edited by
        #3

        Hi Simon, The COM component(named ActiveXRAP) I have referred in my project(ActiveXRAPLib) is displayed as namespace. namespace RAPClient { public partial class Form1 : Form { string output; /* this is the library exposed as namespace and it contains a class RAPCLientX where in there is a method Connect(..). Now declaring the below way is showing an error that states ActiveX... is used as a type since its a namespace. kindly help me out. */ **ActiveXRAPLib.RAPClientX objRAP;** public Form1() { InitializeComponent(); } private void bConnect_Click(object sender, EventArgs e) { } } } Regards, LG.

        lgatcodeproject

        S R 2 Replies Last reply
        0
        • L lgatcodeproject

          Hi Simon, The COM component(named ActiveXRAP) I have referred in my project(ActiveXRAPLib) is displayed as namespace. namespace RAPClient { public partial class Form1 : Form { string output; /* this is the library exposed as namespace and it contains a class RAPCLientX where in there is a method Connect(..). Now declaring the below way is showing an error that states ActiveX... is used as a type since its a namespace. kindly help me out. */ **ActiveXRAPLib.RAPClientX objRAP;** public Form1() { InitializeComponent(); } private void bConnect_Click(object sender, EventArgs e) { } } } Regards, LG.

          lgatcodeproject

          S Offline
          S Offline
          Simon P Stevens
          wrote on last edited by
          #4

          That looks all right to me. Sorry. Is RAPClientX defiantly a type?

          Simon

          1 Reply Last reply
          0
          • L lgatcodeproject

            Hi Simon, The COM component(named ActiveXRAP) I have referred in my project(ActiveXRAPLib) is displayed as namespace. namespace RAPClient { public partial class Form1 : Form { string output; /* this is the library exposed as namespace and it contains a class RAPCLientX where in there is a method Connect(..). Now declaring the below way is showing an error that states ActiveX... is used as a type since its a namespace. kindly help me out. */ **ActiveXRAPLib.RAPClientX objRAP;** public Form1() { InitializeComponent(); } private void bConnect_Click(object sender, EventArgs e) { } } } Regards, LG.

            lgatcodeproject

            R Offline
            R Offline
            Rob Graham
            wrote on last edited by
            #5

            Are you missing a "using ActiveXWrapLib;" at the top of the class?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups