works okay on another PC

This forum covers issues concerning multiple software products.

works okay on another PC

Postby bjlucas_utec » Wed 20. Dec 2017, 20:47

hello,

When running InitializeBasicComponents(), the bold line below "stsResult = PCANBasic.GetValue" crashes.
This code runs on other PCs. The difference. My PC was just reimaged, now runs Visual Studio 2013 now, and has all new PEAK drivers. I have a PCAN-USB Pro. The handle array looks normal with my device showing up at &h51 and &h52. I can't find any meaningful difference between my PC and other PCs where this still works. The example programs open and run ok. I cannot figure out what I forgot to update, download, or recopy back to my PC. Any ideas would be greatly appreciated.

Brad

stsResult = PCANBasic.GetValue(m_HandlesArray(i), TPCANParameter.PCAN_CHANNEL_CONDITION, iBuffer, System.Runtime.InteropServices.Marshal.SizeOf(iBuffer))

Code: Select all
    Private Sub btnHwRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHwRefresh.Click
        Dim iBuffer As UInt32
        Dim stsResult As TPCANStatus

        ' Clears the Channel combioBox and fill it again with
        ' the PCAN-Basic handles for no-Plug&Play hardware and
        ' the detected Plug&Play hardware
        '
        cbbChannel.Items.Clear()
        Try
            For i As Integer = 0 To m_HandlesArray.Length - 1
                ' Includes all no-Plug&Play Handles
                If m_HandlesArray(i) <= PCANBasic.PCAN_DNGBUS1 Then
                    cbbChannel.Items.Add(FormatChannelName(m_HandlesArray(i)))
                Else
                    ' Checks for a Plug&Play Handle and, according with the return value, includes it
                    ' into the list of available hardware channels.
                    '
--->              stsResult = PCANBasic.GetValue(m_HandlesArray(i), TPCANParameter.PCAN_CHANNEL_CONDITION,
                   iBuffer, System.Runtime.InteropServices.Marshal.SizeOf(iBuffer))

                    If (stsResult = TPCANStatus.PCAN_ERROR_OK) AndAlso (iBuffer = PCANBasic.PCAN_CHANNEL_AVAILABLE) Then
                        cbbChannel.Items.Add(FormatChannelName(m_HandlesArray(i)))
                    End If
                End If
            Next
            cbbChannel.SelectedIndex = cbbChannel.Items.Count - 1
        Catch ex As DllNotFoundException
            '        MessageBox.Show("Unable to find the library: PCANBasic.dll !", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error)
            TextBox2.Text = "PCAN initialization error"
            failcode = 1
            fail_description = "PCN init error"
            Environment.Exit(-1)
        End Try

    End Sub
Last edited by K.Wagner on Thu 21. Dec 2017, 08:00, edited 2 times in total.
Reason: Code formatted for best reading
bjlucas_utec
 
Posts: 3
Joined: Wed 20. Dec 2017, 20:31

Re: works okay on another PC

Postby K.Wagner » Thu 21. Dec 2017, 08:00

Hello,

could you please post the error message being shown by Visual Studio when the program crashes?
Best regards,
Keneth
K.Wagner
Software Development
Software Development
 
Posts: 675
Joined: Wed 22. Sep 2010, 12:36
Location: Darmstadt, Germany

Re: works okay on another PC

Postby bjlucas_utec » Thu 21. Dec 2017, 14:16

Thank you for the quick reply.
Screen shot attached.
Attachments
Error on 144 board.png
Error on 144 board.png (168.62 KiB) Viewed 1110 times
bjlucas_utec
 
Posts: 3
Joined: Wed 20. Dec 2017, 20:31

Re: works okay on another PC

Postby K.Wagner » Thu 21. Dec 2017, 14:37

Hello,

the error message indicates that you are loading the wrong DLL within your project. You probably have a PCAN-Basic file (PCANBasic.dll) in your output folder that not match the platform of your system. If your new PC uses a 64-Bit Windows, then you should check that the PCAN-Basic file used is also 64-Bit. Same for 32-Bit systems.

You can check this by inspecting the properties of the PCANBasic.dll file
Properties.png
PCAN-Basic file properties - 64-Bits
Properties.png (15.2 KiB) Viewed 1110 times
Best regards,
Keneth
K.Wagner
Software Development
Software Development
 
Posts: 675
Joined: Wed 22. Sep 2010, 12:36
Location: Darmstadt, Germany

Re: works okay on another PC

Postby bjlucas_utec » Thu 21. Dec 2017, 16:56

Right on the money! Now working. Thank You!
bjlucas_utec
 
Posts: 3
Joined: Wed 20. Dec 2017, 20:31


Return to Software



This website uses cookies for analytics, for logins to the online shop and the forum, and for the handling of an order. By browsing this website you agree to the use of cookies. Detailed information on their use can be found in our privacy policy.

OKPrivacy Policy