- Home /
pinning in the memory
Hi, my code is
...
...
Private Color[] cols;
Private GCHandle cols_handle
cols = texture.GetPixels(0);
cols_handle = GCHandle.Alloc(cols, GCHandleType.Pinned);
...
...
<Plugin>myFunction(cols_handle.AddrofPinnedObject());
But I am getting on the last line written above InvalidOperationException: The handle is not of Pinned type System.Runtime.InteropServices.GCHandle.AddrOfPinnedObject()
Please someone tell me WHYYYY I am getting this error !!! while I am clearly setting the handle (cols_handle) to type Pinned ??
I have gone mad.. Help would be highly appreciated.
Thanks
Answer by Arjun · Jul 19, 2010 at 09:10 AM
oh gosh, sorry for wasting ur time i used void start() instead of void Start() so it was not initializing the variables , functions and all now its ok
"so it was not initializing the variables"
This helped me for a recent problem, thank you.
Answer by Mike 3 · Jul 16, 2010 at 06:04 PM
Are you absoloutely sure that cols_handle is called after being pinned, and isn't freed before being used?
The code itself looks fine, but it'll screw up if the bits where you put ... modify the handle
yes i m sure. infact after getting this error i removed the lines which free the handle. main puzzle is that the same code is running in TextureUnityProject example given in unity3d documentation. i just copied the lines...
Hi, thanks for responding here is the link to the exact code. (code was too long to write here) i hope u could solve the mystery. http://dl.dropbox.com/u/5420677/NewBehaviourScript.cs
maybe this page could help you to figure it out http://www.gnu.org/software/dotgnu/pnetlib-doc/System/Runtime/InteropServices/GCHandle.html#GCHandle.AddrOfPinnedObject%20$$anonymous$$ethod
i am getting the same error message
Your answer
Follow this Question
Related Questions
Trying to get value from unmanaged memory 1 Answer
Will this be an instance or a pointer? 3 Answers
Make a dotted line from an object to the mouse 2d 2 Answers
Can I set a specific Pointer for the EventTrigger on Buttons for example? 0 Answers
How can I get the PointerEventData included in StandaloneInputModule ? 0 Answers