Results 1 to 11 of 11

Thread: Invoke Event Call Backs

  1. #1

    Thread Starter
    Member
    Join Date
    May 2019
    Posts
    52

    Invoke Event Call Backs

    Hi,

    I am trying to work out why my program is erroring on load.

    It is because of Phidget22.Phidget.InvokeCallbacks = True on debug its coming up as False and then throws a error.

    Is there anyway i can turn this on.......

    Name:  InvokeEvent.jpg
Views: 283
Size:  15.0 KB

    i am trying to develop a RFID Clocking in system with a SQL DB backend and the RFID companies code works correctly with the same code lines were mine does not.

    Thanks in advance,

    James

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,760

    Re: Invoke Event Call Backs

    Instead of taking a screenshot of the code, could you copy/paste the code inside of [CODE][/CODE] tags?
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3

    Thread Starter
    Member
    Join Date
    May 2019
    Posts
    52

    Re: Invoke Event Call Backs

    Quote Originally Posted by dday9 View Post
    Instead of taking a screenshot of the code, could you copy/paste the code inside of [CODE][/CODE] tags?
    When I get back into the office will post the code what areas do you require?

  4. #4
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,760

    Re: Invoke Event Call Backs

    Presumably the part you have screenshotted.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,348

    Re: Invoke Event Call Backs

    Quote Originally Posted by VBJames View Post
    what areas do you require?
    The parts that you think are relevant to the problem.

  6. #6
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Invoke Event Call Backs

    I don't usually need to add code to the New method, but I think if I did, I would add it after the comment where it says "Add any Initialization...".

    Adding code before the components are initialized seems like you're asking for problems.
    I could be wrong though, since I haven't added code to the method (that I can remember.... I'm old).
    "Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930

  7. #7

    Thread Starter
    Member
    Join Date
    May 2019
    Posts
    52

    Re: Invoke Event Call Backs

    Here is the code

    Code:
    Imports System.Runtime.InteropServices
    Imports System.Data.SqlClient
    Imports System.Data
    Imports Phidget22
    Imports Phidget22.Events
    
    Public Class Form1
        Dim WithEvents device As Phidget22.RFID
        Dim open As ExampleUtils.ExampleUtils.CommandLineOpen
        Dim errorBox As ErrorEventBox
        Dim runonce As Boolean = False
    
        Public Sub New()
            open = New ExampleUtils.ExampleUtils.CommandLineOpen(Me)
            ' This call is required by the Windows Form Designer.
            Phidget22.Phidget.InvokeEventCallbacks = True
            InitializeComponent()
            ' Add any initialization after the InitializeComponent() Call.
        End Sub
        Public Sub New(ByVal commandLine As String())
            open = New ExampleUtils.ExampleUtils.CommandLineOpen(Me)
            open.commandLine = commandLine
            Phidget22.Phidget.InvokeEventCallbacks = True
            InitializeComponent()
        End Sub
    When i debug the
    Code:
    Phidget22.Phidget.InvokeEventCallbacks = True
    is showing as False.

    Cheers James

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,348

    Re: Invoke Event Call Backs

    So as suggested in post #6, the auto-generated comment explicitly states that you should put your initialisation code after the call to InitializeComponent and yet you have ignored that and put it first. Why would you think that that was a good idea? Fix that obvious issue and then get back to us if there's still an issue.

    Also, your constructors are wrong. You should put everything you can into the parameterless constructor and then, unless it's impossible for some reason, call the parameterless constructor in the other one:
    vb.net Code:
    1. Public Sub New()
    2.     InitializeComponent()
    3.    
    4.     'Your code goes here, as is clear simply by reading what's in front of you.
    5. End Sub
    6.  
    7. Public Sub New(ByVal commandLine As String())
    8.     Me.New()
    9.  
    10.     open.commandLine = commandLine
    11. End Sub

  9. #9

    Thread Starter
    Member
    Join Date
    May 2019
    Posts
    52

    Re: Invoke Event Call Backs

    I have done as jmcilhinney advises but the same issue

    Phidget22.Phidget.InvokeEventCallbacks = True is still false on debug and crashes.

    Cheers James

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,348

    Re: Invoke Event Call Backs

    Show us the actual code you have now and indicate exactly where the exception is thrown. You have no idea the number of times that people have indicated that they have done as instructed but it still didn't work, only for us to find out later than they didn't do as instructed at all. If you want help with something that doesn't work, ALWAYS show us what that is. If you make changes, show us the new code. NEVER make us assume or guess because if we assume or guess incorrectly then it's a waste of our time and yours.

  11. #11

    Thread Starter
    Member
    Join Date
    May 2019
    Posts
    52

    Re: Invoke Event Call Backs

    Thanks for all the help I have worked it and my app is running correctly and can now start developing it.

    Cheers James

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