473,503 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GCHandle status

Hi,
please pardon me if I sound stupid. I want to check the status of the
GChandle to see if a previous call to Alloc is successful, or whether it
has been called before hand, before I call the Free function. I tried
the following code,

GCHandle gch;
gch=GCHandle::Alloc(Mydelegate); <== How do I check if this is successful?
gch.Free();

Refering to MSDN, it mentioned only what happens when Alloc is
successful, not when Alloc failed. in C++/CLI, I tried
if (gch.IsAllocated)
gch.Free();

but it gave me an "Invalid Operation exception, handle not initialized"
when I purposely omit the alloc statement. So, how should I handle
this? .NET can't be this stupid that the object does not know its own
status. Can someone help me? the new MSDN gives me all the info except
the one I need.
Feb 1 '06 #1
0 1092

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

Similar topics

1
2592
by: Hexar Anderson | last post by:
Why can't you pin an enumeration? For example, the with the following code: public enum MyEnum : byte { ValueOne = 1, ValueTwo = 2 } public class MyClass {
0
1251
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...
4
2643
by: darrel | last post by:
I'm trying to get a page up using some sample code that interfaces with a 3rd party application using .net. The sample code the company provides, when I run it, produces this error: ...
8
2331
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
7898
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....
1
4603
by: =?Utf-8?B?SkE=?= | last post by:
I use a method for threading that instantiates an object that is a wrapper to a DLL (written in C). The wrapper class is passed a byte array, and then does GCHandle handle =...
7
6423
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...
0
1414
by: DaTurk | last post by:
Hi, I need to have a native class hold on to a managed function pointer. Not a unmanaged class in a manged block. I mean an unmanaged class in an unmanaged block via #pragma unmanaged. I'm...
0
1858
by: mike1reynolds | last post by:
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...
0
7091
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
7282
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,...
1
6998
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5018
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4680
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3162
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1516
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.