? implement a COM Components method.
-
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
-
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
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
-
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
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
-
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
That looks all right to me. Sorry. Is RAPClientX defiantly a type?
Simon
-
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
Are you missing a "using ActiveXWrapLib;" at the top of the class?