Results 1 to 4 of 4

Thread: [RESOLVED] callback from com doesnt work

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2006
    Posts
    58

    Resolved [RESOLVED] callback from com doesnt work

    Hi
    I have an activex with some callbacks..How can get my values...??

    public abstract virtual System.Int32 GetValue ( System.Int32 myId , System.Object Value )

    System.Object Value is the callback...

    So..i can do f.ex
    int id = 5000;
    object a="";

    myControl.getValue(id,ref a);

    ...however, this gives me datatype mismatch..
    The callback is supposed to be a "ref object" type, how can i get this to work?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: callback from com doesnt work

    Methods arguments that require callbacks are delegates in .NET code. You can't pass a string to an argument that expects a delegate. An empty string is not a null value. It is a string with no characters in it, but it is still very definitely a string. If you don't want to p[ass a callback method, assuming that the method you're calling will allow it, then you need to explicitly pass null. Otherwise you need to create an appropriate delegate and pass that.

    A callback is a method that gets called from the remote location. In .NET a delegate is an object that contains a reference to a method. You pass the delegate to the method argument and the method it refers to is what gets called from the remote location. If you want more information delegates and their use just search MSDN.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2006
    Posts
    58

    Re: callback from com doesnt work

    Ay, very enlightning :-)
    Ill check it out and come back if i still have no clue on what to do

    Madsun

  4. #4

    Thread Starter
    Member
    Join Date
    Mar 2006
    Posts
    58

    Re: callback from com doesnt work

    figured it out... :-)

    object a = null;
    myControl.getValue(1000,ref a);

    That solves it, thanks for the tip!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width