Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Arjun · Jul 16, 2010 at 05:56 PM · pointerinterop

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1

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

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Mike 3 · Jul 19, 2010 at 10:13 AM 0
Share

Heh, just noticed that when I checked, glad it's fixed :)

avatar image fprost · May 21, 2015 at 07:41 AM 0
Share

"so it was not initializing the variables"

This helped me for a recent problem, thank you.

avatar image
0

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

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Arjun · Jul 17, 2010 at 03:03 AM 0
Share

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...

avatar image StephanK · Jul 17, 2010 at 05:43 AM 0
Share

Could you post the exact code you are using?

avatar image Arjun · Jul 19, 2010 at 08:38 AM 0
Share

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

avatar image Arjun · Jul 19, 2010 at 08:40 AM 0
Share

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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges