The error occures after the function ends. I have posted the code on my weblog:
mkenyon2.blogspot.com
Titled: Okay, latest and greatest on this project.
This project is using VB .Net 1.1
>The error occures after the function ends. I have posted the code on my weblog:
>mkenyon2.blogspot.com
>Titled: Okay, latest and greatest on this project.
>
>This project is using VB .Net 1.1
Next time, please include relevant parts of the code in your message
so we don't have to visit your blog to find out wwhat ythe problem is.
It's hard to say what's wrong without seeing the native function
declarations. Some working native calling code would also be helpful.
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
M K - 13 Dec 2004 20:49 GMT
Native Def:
//Get the size and type for the specified attribute ID.//
KPDCStatus KPDCGetAttributeInfo(KPDCOpaqueRef inRef, KPDCAttributeID
inAttrID, KPDCDataTypes *outAttrType, KPDCUInt32 *outAttrSize);
My wrap:
Declare Auto Function KGetAttributeInfo Lib "DCSPro4SLR.dll" Alias
"KPDCGetAttributeInfo" (ByVal inRef As IntPtr, ByVal inAttrID As Integer,
ByRef outAttrType As KPDCDataTypes, ByRef outAttrSize As Integer) As Integer
Native Def:
//Get the value of the specified attribute ID. If the attribute is the
KPDCPropValueID of a property, then the value of the property will be
retrieved from the camera.//
KPDCStatus KPDCGetAttributeValue(KPDCOpaqueRef inRef, KPDCAttributeID
inAttrID, KPDCUInt32 *inOutAttrSize,
My wrap:
Declare Auto Function KGetAttributeValue Lib "DCSPro4SLR.dll" Alias
"KPDCGetAttributeValue" (ByVal inRef As IntPtr, ByVal inAttrID As Integer,
ByRef inOutAttrSize As Integer, ByVal outAttrValue As IntPtr) As Integer
Native Def:
//Allocate a property iterator for camera properties.//
KPDCStatus KPDCAllocPropertyIterator ( KPDCCameraRef inCameraRef,
KPDCPropertyIterRef *outRef);
My Wrap:
Declare Auto Function KAllocPropertyIterator Lib "DCSPro4SLR.dll" Alias
"KPDCAllocPropertyIterator" (ByVal inCameraRef As IntPtr, ByRef outRef As
IntPtr) As Integer
Native Code:
//Return a reference to the first item that has the string specified by
inName and the value of its name attribute. The iterator points to the found
item. A subsequent call to KPDCIteratorNext returns the item following the
found item in the list.//
KPDCStatus KPDCIteratorFind(KPDCIteratorRef inIteratorRef, const char
*inName, KPDCOpaqueRef *outFoundItemRef);
My Wrap:
Declare Auto Function KIteratorFind Lib "DCSPro4SLR.dll" Alias
"KPDCIteratorFind" (ByVal inIteratorRef As IntPtr, ByVal inName As
System.Text.StringBuilder, ByRef outFoundItemRef As IntPtr) As Integer
Native Code:
//Return a reference to the next enumerated item. After creating a new
iterator or calling KPDCIteratorReset, this function returns the first item.
If there are no more items, outNextItemRef will not be valid.//
KPDCStatus KPDCIteratorNext(KPDCIteratorRef inIteratorRef, KPDCOpaqueRef
*outNextItemRef);
My Wrap:
Declare Auto Function KIteratorNext Lib "DCSPro4SLR.dll" Alias
"KPDCIteratorNext" (ByVal inIteratorRef As IntPtr, ByRef outNextItemRef As
IntPtr) As Integer
Native Code:
//Reset the iterator to point to the beginning of the list.//
KPDCStatus KPDCIteratorReset(KPDCIteratorRef inIteratorRef);
My Wrap:
Declare Auto Function KIteratorReset Lib "DCSPro4SLR.dll" Alias
"KPDCIteratorReset" (ByVal inIteratorRef As IntPtr) As Integer
Mattias Sj?gren - 19 Dec 2004 23:29 GMT
>My Wrap:
> Declare Auto Function KIteratorFind Lib "DCSPro4SLR.dll" Alias
>"KPDCIteratorFind" (ByVal inIteratorRef As IntPtr, ByVal inName As
>System.Text.StringBuilder, ByRef outFoundItemRef As IntPtr) As Integer
Most of your Declare statements look fine, except perhaps this one
where you should be using Anis rather than Auto.
But your calling code you posted on your blog looks a bit weird. Why
are you initializing all your IntPtr variables to point to a single
byte allocated from the unmanaged heap?
And the first function you call is KIteratorNext. Aren't you supposed
to first initialize the iterator somehow?
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
M K - 13 Dec 2004 20:55 GMT
Thank you for your patience. I noticed this article on your site:
http://support.microsoft.com/?kbid=309327
It breakes unmanaged resources into 2 types, handles to operating system
objects, and non operating system objects.
What would constitute an operating system object?
M K - 13 Dec 2004 21:01 GMT
Sorry I keep doing this, but as I type things out, I'm working it out in my
head. You should also know that in the C++ demo code, they have a typedef
section that looks like this:
TypeDefs in demo C++ code:
typedef void* KPDCOpaqueRef;
typedef KPDCOpaqueRef KPDCLibMgrRef;
typedef KPDCOpaqueRef KPDCIteratorRef;
typedef KPDCIteratorRef KPDCCameraIterRef;
typedef KPDCOpaqueRef KPDCCameraRef;
typedef KPDCIteratorRef KPDCPropertyIterRef;
typedef KPDCOpaqueRef KPDCPropertyRef;
typedef KPDCIteratorRef KPDCDirectoryIterRef;
typedef KPDCOpaqueRef KPDCDirItemRef;
typedef KPDCOpaqueRef KPDCIORef;
typedef KPDCOpaqueRef KPDCImageRef;
Most of the function declarations use these. After looking through the
article I mentioned in the previous reply, I am wondering, should I use
HandleRef instead of IntPtrs? And how do I know when to use what?
I really think that this is something with garbage collection, because it is
happening after the managed function (which calls to the unmanaged function)
is called.
I think I should clarify, the DLLs I am working with communicate with a
camera via FireWire.