473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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_StartViewFinder Lib "PRSDK.dll" Alias
"PR_RC_StartViewFinder" (ByVal CameraHandle As System.UInt32, ByVal Context
As System.UInt32, ByRef pViewFinderCB As prViewFinderCB) As Integer
'C++ doe:
'typedef prResponse prSTDCALL prRC_StartViewFinder(
' 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(UnmanagedType.FunctionPtr)Private aa As PSReCWrap.prViewFinderCB

Public Shared Function ViewFinderCallBackFunc(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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
...
aa = New PSReCWrap.prViewFinderCB(AddressOf ViewFinderCallBackFunc)
**** 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.

Jan 27 '07 #1
3 1511
"Farsad" <Fa****@discussions.microsoft.comschrieb
Declare Auto Function prRC_StartViewFinder Lib "PRSDK.dll" Alias
"PR_RC_StartViewFinder" (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_StartViewFinder(
' prHandle CameraHandle,
' prContext Context,
' prViewFinderCB* pViewFinderCB
');

Armin
Jan 28 '07 #2
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
http://www.developmentnow.com
Jun 19 '07 #3
Following is my EMAIL

fa**********@gmail.com

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

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
Jun 19 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: pvdm | last post by:
Hi, I am writing an app which encapsulates a multimedia timer. I implemented a TimerProc as static member function and a static member variable pThis as pseudo this variable to access in the...
3
by: ThinkRS232 | last post by:
I have a Win32 DLL that has a standard _stdcall (WINAPI) exports. I am able to call these fine from C#. One call in particular however has a callback to a CDECL function. How would I set that up?...
4
by: H.B. | last post by:
Hi, I successfully implement a static callback function for my dll usign delegates. Now, I need to use member function instead of static function. How can I make that (in Managed C++). Hugo
8
by: kurtcobain1978 | last post by:
-------------------------------------------------------------------------------- I need to do the exactly same thing in VB.NET. Load a unmanaged C DLL dynamically and then call a function in...
1
by: Timbo | last post by:
Hi all, This is my first message here so i'll try and include all the information that will help you help me out, if possible. Basically I am using C# in ASP.NET 2.0 and have a Repeater...
4
by: Kyku | last post by:
Hello all, I'm in a process of writing a small Linux C++ program for discovering repeaded files over a filesystem. One part of this task is traversing a directory structure. This is done by the...
7
by: harishashim | last post by:
I am wrapping a digital camera API using Managed C++ VS .NET 2003). I have this function that called as bellow in the API sample. err = PR_RC_StartViewFinder( m_hCamera, //line 1...
1
by: stillh2os | last post by:
Hello. I'm new to .NET, and I'm trying to implement a callback function. I want my managed C++ code to call an unmanaged function, passing in a callback function that the unmanaged C/C++ code...
10
by: SQACPP | last post by:
Hi, I try to figure out how to use Callback procedure in a C++ form project The following code *work* perfectly on a console project #include "Windows.h" BOOL CALLBACK...
40
by: Angus | last post by:
Hello I am writing a library which will write data to a user defined callback function. The function the user of my library will supply is: int (*callbackfunction)(const char*); In my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.