callback function error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?RmFyc2Fk?=

    callback function error

    Hi
    I have a dll file (PRSDK.dll) for canon camera sdk and wish create a wrapper
    and sample program for this in vb.net.
    I create a class (PSReCWrap) and declared wrapper in this.
    my function in wrapper for get viewfinder is:

    Public Delegate Function prViewFinderCB( ByVal CameraHandle As
    System.UInt32, ByVal Context As System.UInt32, ByVal Size As System.UInt32,
    ByRef pVFData As IntPtr) As System.UInt32
    'C++ doe:
    'typedef prResponse prSTDCALL prViewFinderCB (
    ' prHandle CameraHandle,
    ' prContext Context,
    ' prUInt32 Size,
    ' prVoid * pVFData
    ');

    Declare Auto Function prRC_StartViewF inder Lib "PRSDK.dll" Alias
    "PR_RC_StartVie wFinder" (ByVal CameraHandle As System.UInt32, ByVal Context
    As System.UInt32, ByRef pViewFinderCB As prViewFinderCB) As Integer
    'C++ doe:
    'typedef prResponse prSTDCALL prRC_StartViewF inder(
    ' prHandle CameraHandle,
    ' prContext Context,
    ' prViewFinderCB* pViewFinderCB
    ');

    now I create a sample program that work with PSReCWrap to get picture from
    camera.
    my sample code for viewfinder is:

    Imports System.Runtime. InteropServices

    <MarshalAs(Unma nagedType.Funct ionPtr)Private aa As PSReCWrap.prVie wFinderCB

    Public Shared Function ViewFinderCallB ackFunc(ByVal CameraHandle As
    System.UInt32, ByVal Context As System.UInt32, ByVal Size As System.UInt32,
    ByRef pVFData As IntPtr) As Integer
    '!!!!!!!! in this section i wish get viewfinder data from pVFData !!!!!!
    Return 0
    End Function

    Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
    System.EventArg s) Handles MyBase.Load
    ...
    aa = New PSReCWrap.prVie wFinderCB(Addre ssOf ViewFinderCallB ackFunc)
    **** perror = PSReCWrap.prRC_ StartViewFinder (prHandle, 0, aa)
    Label1.Text = perror.ToString ("x")
    End Sub

    i get this error for **** line:
    Unhandled exception at 0x0027e692 in Sample.exe: 0xC0000005: Access
    violation writing location 0x00000001.
    I thinks this error comes from a marshalling error between .Net and the SDK
    when passing the address of the callback function. I sure send first and
    second parameter correct becuase this my perevious line work correctly and my
    camera lens jump.

    are you have any solution.

    very thanks.

  • Armin Zingler

    #2
    Re: callback function error

    "Farsad" <Farsad@discuss ions.microsoft. comschrieb
    Declare Auto Function prRC_StartViewF inder Lib "PRSDK.dll" Alias
    "PR_RC_StartVie wFinder" (ByVal CameraHandle As System.UInt32, ByVal
    Context As System.UInt32, ByRef pViewFinderCB As prViewFinderCB) As
    Integer

    I'm not sure, but i would try to pass the last argument "ByVal".

    'C++ doe:
    'typedef prResponse prSTDCALL prRC_StartViewF inder(
    ' prHandle CameraHandle,
    ' prContext Context,
    ' prViewFinderCB* pViewFinderCB
    ');



    Armin

    Comment

    • Farhan Tahir

      #3
      RE: callback function error

      Dear Farsad,

      Could you please share PRSDK.dll with me. I have developed a solution without this DLL but this dll is missing. I will share after completing my project.

      Please share it with me

      From http://www.developmentnow.com/g/38_2...tion-error.htm

      Posted via DevelopmentNow. com Groups
      DevelopmentNow is an award-winning creative software development agency integrating mobile, web, hardware, mixed reality, and emerging technology.

      Comment

      • Farhan Tahir

        #4
        RE: callback function error

        Following is my EMAIL

        farhan.tahir@gm ail.com

        From http://www.developmentnow.com/groups...hreadid=919459

        Posted via DevelopmentNow. com Groups
        DevelopmentNow is an award-winning creative software development agency integrating mobile, web, hardware, mixed reality, and emerging technology.

        Comment

        Working...