Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 731
  • Last Modified:

garbage collector VB.NET

How can i avoid garbage collector releasing the delegate function's address. By default, the GC is on. I've no control over GC. When i pass the AddressOf callback funciton to an unmanaged DLL, the address is lost as soon as the function passing the address of the callback returns. each time the address is a new and when there is a mis-match between the calling address and the actual address, the applicaition faults.

regards

pawan

0
pawan_marwar
Asked:
pawan_marwar
1 Solution
 
KarunSKCommented:
You have to use GCHandle methods to do this. Typically, you create a handle to the managed object using GCHandle.Alloc(), and pass this handle to the unmanaged DLL.

Here is an example from MSDN:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcongchandlesample.asp

HTH,
Karun.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now