473,387 Members | 1,705 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,387 software developers and data experts.

Marshalling: GCHandle Pinning vs Marshal.PtrToStruct & StructToPtr?

I am calling legacy Btrieve database functions using StructureToPtr and
PtrToStructure, but I think that I am getting memory corruption from improper
marshalling, and I am unclear about when memory is being copied vs memory
being pinned. Does StructureToPtr pin, or just copy?

I've seen references to pinning memory using GCHandles while googling the
topic, and I suspect that I might do better using GCHandle functions rather
than Marshal functions since these buffers are reused often. I've spent hours
on google trying to get a better understanding, but I'm still in a fog. Which
is the best approach for calling old C++ DLLs?

Jul 2 '08 #1
0 1854

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

Similar topics

4
by: TT (Tom Tempelaere) | last post by:
Hi people I am wrapping a C dll using PInvoke from C#. I need to wrap the following signature in C int dma_start( const UCHAR* data, UINT data_length ) The function should start with a DMA...
1
by: Tajmiester | last post by:
Hi, And thanks for any help. I am having trouble declaring a struct containing strings that can be Serialized using the following functions. It works, but the strings wont store the right number...
0
by: Motoxcat | last post by:
Greetings I am writing some MC++ code to interoperate between a legacy C-languiage dll and C#. I need to specify a callback function to the managed portion for the dll to provide more detailed...
8
by: XYZ | last post by:
I need to pass the address of a variableto some win32 API functions like RTLMoveMemory I noticed some weird behavior when pinning objects and using the handle's pointer to write data to the...
2
by: steve | last post by:
Hi all, I want to understand more about how the pinvoke pinning process works. I'm writing some code that calls DeviceIoControl. DeviceIoControl provides a generic interface to device drivers....
3
by: markb | last post by:
Hi My C# app is being called from a callback from an unmanaged DLL. One of the parameters of the callback is of type BOOL. I am using PInvoke to marshal this to a (managed) bool. The problem is...
7
by: DaTurk | last post by:
Hi, I'm coding up an application that has a native c++ layer, asynchronously calling callback in a CLI layer. We originally did this with static inline methods in the CLI layer, but this...
2
by: d-42 | last post by:
Hi, I'm pretty sure I've just got a Marshalling problem, but I'm completely stumped. If there is a better newsgroup to post this in, please point me towards it. First I'm trying to use...
1
by: roche72 | last post by:
I am having some trouble marshalling data between c++/C# Here is the C++ code: --------------------------------------------------------------------------------- typedef struct { ...... ...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.