Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / January 2004

Tip: Looking for answers? Try searching our database.

Access a COM Component Library

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bradley Grant - 26 Jan 2004 04:11 GMT
I'm trying to access a COM Component with C#. And I get the following error

C:\Visual C# Step by Step\Lesson 1\USB\Form1.cs(172): Method 'USB.Form1.button5_OnChange(object, System.EventArgs)' does not match delegate 'void BDaq._IBBDaqEnumEvents_OnChangeEventHandler()

C:\Visual C# Step by Step\Lesson 1\USB\Form1.cs(173): Method 'USB.Form1.button5_OnChange(object, System.EventArgs)' does not match delegate 'void BDaq._IBBDaqDeviceEvents_OnChangeEventHandler()

I created the Object a Delegate and a method, I believe the problem is the augument in the method button5_OnChange(object sender, System.EventArgs e) but I'm not sure what I should put there, here is some of the code

Any suggestions would be appreciated

public class Form1 : System.Windows.Forms.For
    {
        private BDaq.BBDaqEnum Connected = new BDaq.BBDaqEnum()
        private BDaq.BBDaqDevice Device1 = new BDaq.BBDaqDevice()
   
    public Form1(
    {           
        InitializeComponent()
       
        Connected.OnChange += new BDaq._IBBDaqEnumEvents_OnChangeEventHandler(button5_OnChange)
        Device1.OnChange += new BDaq._IBBDaqDeviceEvents_OnChangeEventHandler(button5_OnChange)
   

private void button5_OnChange(   object sender, System.EventArgs e  
   
        Do somethin
Uwe Hafner - 27 Jan 2004 16:28 GMT
Hi,

probably your method button5_OnChange does not have the same signature as
the delegate (i.e. the same arguments and return value).

What does the delegate declaration look like? Make button5_OnChange look the
same.

hth
Uwe

it usually means your eventhandler does not have the correct signature. It
has to look like the delegate declaration
> I'm trying to access a COM Component with C#. And I get the following error.
>
> C:\Visual C# Step by Step\Lesson 1\USB\Form1.cs(172): Method 'USB.Form1.button5_OnChange(object, System.EventArgs)' does not match
delegate 'void BDaq._IBBDaqEnumEvents_OnChangeEventHandler()'

> C:\Visual C# Step by Step\Lesson 1\USB\Form1.cs(173): Method 'USB.Form1.button5_OnChange(object, System.EventArgs)' does not match
delegate 'void BDaq._IBBDaqDeviceEvents_OnChangeEventHandler()'

>  I created the Object a Delegate and a method, I believe the problem is the augument in the method button5_OnChange(object sender, System.EventArgs
e) but I'm not sure what I should put there, here is some of the code.

> Any suggestions would be appreciated.
>
[quoted text clipped - 15 lines]
> Do something
> }
Bradley - 27 Jan 2004 17:26 GMT
Thank for your reply, I guess that is the question I'm asking what the signature, argument in the button5_OnChange method should look like. My guess is that  object sender, System.EventArgs e, is the usual standard that Visual studio puts there,  that it is the standard for Net components, but not for the COM Component that I am trying to access. I guess I just do not have enough understanding in this area, and if you have any ideas or books or know of any resources that I might learn more about this, I would be interested. Thanks again for your reply

----- Uwe Hafner wrote: ----
   
    Hi
   
    probably your method button5_OnChange does not have the same signature a
    the delegate (i.e. the same arguments and return value)
   
    What does the delegate declaration look like? Make button5_OnChange look th
    same
   
    ht
    Uw
   
    it usually means your eventhandler does not have the correct signature. I
    has to look like the delegate declaratio
    "Bradley Grant" <bradgrant@shaw.ca> schrieb im Newsbeitra
    news:96BC34BD-7108-475E-B592-FF45E9A7E863@microsoft.com..
    > I'm trying to access a COM Component with C#. And I get the followin
    error
    >> C:\Visual C# Step by Step\Lesson 1\USB\Form1.cs(172): Metho
    'USB.Form1.button5_OnChange(object, System.EventArgs)' does not matc
    delegate 'void BDaq._IBBDaqEnumEvents_OnChangeEventHandler()
    >> C:\Visual C# Step by Step\Lesson 1\USB\Form1.cs(173): Metho
    'USB.Form1.button5_OnChange(object, System.EventArgs)' does not matc
    delegate 'void BDaq._IBBDaqDeviceEvents_OnChangeEventHandler()
    >>  I created the Object a Delegate and a method, I believe the problem i
    the augument in the method button5_OnChange(object sender, System.EventArg
    e) but I'm not sure what I should put there, here is some of the code
    >> Any suggestions would be appreciated
    >> public class Form1 : System.Windows.Forms.For
    >
    > private BDaq.BBDaqEnum Connected = new BDaq.BBDaqEnum()
    > private BDaq.BBDaqDevice Device1 = new BDaq.BBDaqDevice()
    >
    > public Form1(
    >
    > InitializeComponent()
    >> Connected.OnChange += ne
    BDaq._IBBDaqEnumEvents_OnChangeEventHandler(button5_OnChange)
    > Device1.OnChange += ne
    BDaq._IBBDaqDeviceEvents_OnChangeEventHandler(button5_OnChange)
    >
    >>> private void button5_OnChange(   object sender, System.EventArgs e  
    >
    > Do somethin
Uwe Hafner - 28 Jan 2004 08:47 GMT
Hi,

The error message should give you some hints. If that is the full error
message it looks like your Event does not have any arguments and return
values. Otherwise it might look like this (example):
Method 'USB.Form1.button5_OnChange(object, System.EventArgs)' does not match
delegate 'void BDaq._IBBDaqDeviceEvents_OnChangeEventHandler(object)'
In which case it would expect an object as argument.

If you have VS.NET 2003 the IDE can make the declarations for you. Just
enter

myClass.MyEvent +=

After the "=" sign the tooltip should ask you to push "Tab" to finish the
line for you like this:
myClass. MyEvent += new Handler(myHandler)
Then it will have a second tooltip and it asks you again to push "Tab" to
make a method declaration "myHandler" for you.

Most times you should get the information about the signature from
documentation of the COM Object you are using. Maybe you can get some
information from the object browser but I am not sure if it shows this info.

hth
Uwe

> Thank for your reply, I guess that is the question I'm asking what the signature, argument in the button5_OnChange method should look like. My
guess is that  object sender, System.EventArgs e, is the usual standard that
Visual studio puts there,  that it is the standard for Net components, but
not for the COM Component that I am trying to access. I guess I just do not
have enough understanding in this area, and if you have any ideas or books
or know of any resources that I might learn more about this, I would be
interested. Thanks again for your reply.

> ----- Uwe Hafner wrote: -----
>
[quoted text clipped - 42 lines]
>      > Do something
>      > }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.