Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Marshal.PtrToStructure(pointer, Point) returns error.

Posted on 2008-10-28
2
Medium Priority
?
3,100 Views
Last Modified: 2013-12-17
Hi,

When i use the Marshal.PtrToStructure i get the following error
The structure must not be a value class.Parameter name: structure.

I pass the function a IntPtr and and a reference to a structure Point.

As far as i can see this is done like Micrsoft says it's supposed to be done.
0
Comment
Question by:Kapalua
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
mac-will earned 750 total points
ID: 22823290
Hmm... try adding [StructLayout(LayoutKind.Sequential)] above your struct.

Checkout: http://msdn.microsoft.com/en-us/library/0t2cwe11(vs.71).aspx
0
 

Author Closing Comment

by:Kapalua
ID: 31510702
Thanks!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question