Click here to Skip to main content
15,901,122 members
Home / Discussions / C#
   

C#

 
GeneralRe: hexadecimal convertions and add on datagrid Pin
Mohammad Daba'an5-Feb-07 0:04
Mohammad Daba'an5-Feb-07 0:04 
GeneralRe: hexadecimal convertions and add on datagrid Pin
Luc Pattyn5-Feb-07 0:45
sitebuilderLuc Pattyn5-Feb-07 0:45 
GeneralRe: hexadecimal convertions and add on datagrid Pin
Mohammad Daba'an5-Feb-07 1:02
Mohammad Daba'an5-Feb-07 1:02 
GeneralRe: hexadecimal convertions and add on datagrid Pin
Luc Pattyn5-Feb-07 1:21
sitebuilderLuc Pattyn5-Feb-07 1:21 
GeneralRe: hexadecimal convertions and add on datagrid Pin
gauthee5-Feb-07 0:49
gauthee5-Feb-07 0:49 
GeneralRe: hexadecimal convertions and add on datagrid Pin
Mohammad Daba'an5-Feb-07 1:05
Mohammad Daba'an5-Feb-07 1:05 
GeneralRe: hexadecimal convertions and add on datagrid Pin
gauthee5-Feb-07 1:27
gauthee5-Feb-07 1:27 
QuestionMarshalling LPVOID Pin
Quiltfish4-Feb-07 21:47
Quiltfish4-Feb-07 21:47 
G'day!

I'm currently writing a program that imports and uses functions from an unmanaged DLL. One of these functions expect as a parameter a struct containing some data (whose types I have previously passed successfully to other functions in the same dll) and an array of a struct containing an LPVOID type and a function pointer(which I have sucessfully passed). I don't understand how marshalling this type should work, if anyone could enlighten me, I'd be most thankful. Heres my current implementation:
<br />
[StructLayout(LayoutKind.Sequential,Pack = 0)]<br />
public struct StructA<br />
{<br />
 // Misc data<br />
 public StructB[] sBArray;<br />
}<br />
<br />
[StructLayout(LayoutKind.Sequential,Pack = 0)]<br />
public struct StructB<br />
{<br />
 [MarshalAs(UnmanagedType.FunctionPtr)]<br />
 public aDelegate delegateMember;<br />
 public object TheProblemChild; //The Unmanaged DLL expects an LPVOID type here<br />
}<br />
<br />
public class Bleh<br />
{<br />
[DllImport("Unmanaged.dll", EntryPoint = "UnmanagedImport")]<br />
        private static extern int UnmanagedImport([MarshalAs(UnmanagedType.Struct)] StructA sA);<br />
 public int CallUnmanagedFunc()<br />
 {<br />
  StructA sA = new StructA();<br />
  SA.sBArray = new StructB[7];<br />
<br />
  //Initialize other data...<br />
<br />
  return UnmanagedImport(sA); //This throws an ArgumentException<br />
 }<br />


The indicated position throws an ArgumentException seemingly no matter what I try. The message is "The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))" and the stacktrace points directly to the imported function. In short (;P), I ask: How can I pass, from managed code to unmanaged, a parameter expected to be of type LPVOID?

Sorry if I overwhelmed you, or maybe turned non understandable.Unsure | :~
AnswerRe: Marshalling LPVOID Pin
Martin#5-Feb-07 2:14
Martin#5-Feb-07 2:14 
GeneralRe: Marshalling LPVOID Pin
Quiltfish5-Feb-07 2:36
Quiltfish5-Feb-07 2:36 
QuestionOpacity problems Pin
b43r_3oo34-Feb-07 21:14
b43r_3oo34-Feb-07 21:14 
AnswerRe: Opacity problems Pin
Martin#4-Feb-07 21:41
Martin#4-Feb-07 21:41 
GeneralRe: Opacity problems Pin
b43r_3oo34-Feb-07 22:15
b43r_3oo34-Feb-07 22:15 
GeneralRe: Opacity problems Pin
Martin#4-Feb-07 22:41
Martin#4-Feb-07 22:41 
GeneralRe: Opacity problems Pin
b43r_3oo34-Feb-07 22:55
b43r_3oo34-Feb-07 22:55 
QuestionOutlook 2003 Security Warning Pin
GermanDM4-Feb-07 20:44
GermanDM4-Feb-07 20:44 
AnswerRe: Outlook 2003 Security Warning Pin
Scott Hanslip5-Feb-07 5:00
Scott Hanslip5-Feb-07 5:00 
QuestionSome questions about C# and COM [modified] Pin
sunssuns4-Feb-07 19:28
sunssuns4-Feb-07 19:28 
AnswerRe: Some questions about C# and COM Pin
Judah Gabriel Himango5-Feb-07 11:57
sponsorJudah Gabriel Himango5-Feb-07 11:57 
GeneralRe: Some questions about C# and COM Pin
sunssuns5-Feb-07 21:26
sunssuns5-Feb-07 21:26 
GeneralRe: Some questions about C# and COM Pin
Judah Gabriel Himango6-Feb-07 7:25
sponsorJudah Gabriel Himango6-Feb-07 7:25 
GeneralRe: Some questions about C# and COM Pin
sunssuns6-Feb-07 15:31
sunssuns6-Feb-07 15:31 
GeneralRe: Some questions about C# and COM Pin
Judah Gabriel Himango6-Feb-07 15:53
sponsorJudah Gabriel Himango6-Feb-07 15:53 
GeneralRe: Some questions about C# and COM Pin
sunssuns6-Feb-07 17:57
sunssuns6-Feb-07 17:57 
GeneralRe: Some questions about C# and COM Pin
Judah Gabriel Himango6-Feb-07 18:08
sponsorJudah Gabriel Himango6-Feb-07 18:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.