Click here to Skip to main content
15,888,816 members
Home / Discussions / C#
   

C#

 
GeneralRectangle problem Pin
Rassul Yunussov29-Jun-05 19:47
Rassul Yunussov29-Jun-05 19:47 
GeneralRe: Rectangle problem Pin
mav.northwind29-Jun-05 20:46
mav.northwind29-Jun-05 20:46 
GeneralMDI Application Pin
deep729-Jun-05 19:45
deep729-Jun-05 19:45 
GeneralRe: MDI Application Pin
sreejith ss nair29-Jun-05 21:39
sreejith ss nair29-Jun-05 21:39 
GeneralCollection Pin
Rassul Yunussov29-Jun-05 19:13
Rassul Yunussov29-Jun-05 19:13 
GeneralRe: Collection Pin
Christian Graus29-Jun-05 19:23
protectorChristian Graus29-Jun-05 19:23 
GeneralOleDbTransaction (rollback) Pin
myNameIsRon29-Jun-05 19:12
myNameIsRon29-Jun-05 19:12 
GeneralTrouble with marshalling structure Pin
Josh Lindenmuth29-Jun-05 18:42
Josh Lindenmuth29-Jun-05 18:42 
Hello,

We are trying to marshal a simple C structure within our C# code. All values are coming across except for doubles (bolded below). A double comes across as junk. Any help you can provide would be appreciated.

Here is our C structure:
<br />
struct other_earn {<br />
   short o_id;<br />
   char o_desc[12];<br />
   char o_tpind[2];<br />
   char o_payee[31];<br />
   char o_addr1[31];<br />
   char o_addr2[31];<br />
   char o_addr3[31];<br />
   char o_hours[2];<br />
   double o_amt1;<br />
   short o_dept;<br />
   char o_txficas[2];<br />
   char o_txficam[2];<br />
   char o_txfit[2];<br />
   char o_txfuta[2];<br />
   char o_txsit[2];<br />
   char o_txsuta[2];<br />
   char o_txloc[2];<br />
   short o_mdt;<br />
   char o_wcexempt[2];<br />
}<br />


And here is how we marshal the struct. Note that all fields except the double are marshalled without issue. We have the same problem with all our other structs:

<br />
        [StructLayout(LayoutKind.Sequential)]<br />
        public struct ROtherEarn<br />
        {<br />
            public Int16 o_id;<br />
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 12)]<br />
            public String o_desc;<br />
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)]<br />
            public String o_tpind;<br />
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 31)]<br />
            public String o_payee;<br />
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 31)]<br />
            public String o_addr1;<br />
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 31)]<br />
            public String o_addr2;<br />
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 31)]<br />
            public String o_addr3;<br />
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)]<br />
            public String o_hours;<br />
            public Double o_amt1;<br />
            public Int16 o_dept;<br />
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)]<br />
            public String o_txficas;<br />
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)]<br />
            public String o_txficam;<br />
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)]<br />
            public String o_txfit;<br />
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)]<br />
            public String o_txfuta;<br />
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)]<br />
            public String o_txsit;<br />
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)]<br />
            public String o_txsuta;<br />
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)]<br />
            public String o_txloc;<br />
            public Int16 o_mdt;<br />
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)]<br />
            public String o_wcexempt;<br />
        }<br />


Thanks,
Josh Lindenmuth
GeneralRe: Trouble with marshalling structure Pin
Bojan Rajkovic30-Jun-05 15:50
Bojan Rajkovic30-Jun-05 15:50 
Generalfunction template Pin
BicycleTheif29-Jun-05 17:55
BicycleTheif29-Jun-05 17:55 
GeneralRe: function template Pin
Christian Graus29-Jun-05 18:12
protectorChristian Graus29-Jun-05 18:12 
GeneralI have trouble with fgets function in C code Pin
dinh van hai29-Jun-05 17:20
dinh van hai29-Jun-05 17:20 
GeneralRe: I have trouble with fgets function in C code Pin
Christian Graus29-Jun-05 18:14
protectorChristian Graus29-Jun-05 18:14 
GeneralRun another console application in my console application Pin
eggie529-Jun-05 13:08
eggie529-Jun-05 13:08 
GeneralRe: Run another console application in my console application Pin
Matt Gerrans29-Jun-05 14:37
Matt Gerrans29-Jun-05 14:37 
GeneralRe: Run another console application in my console application Pin
eggie530-Jun-05 6:51
eggie530-Jun-05 6:51 
GeneralRe: Run another console application in my console application Pin
leppie30-Jun-05 7:45
leppie30-Jun-05 7:45 
GeneralRe: Run another console application in my console application Pin
Matt Gerrans30-Jun-05 7:55
Matt Gerrans30-Jun-05 7:55 
GeneralFullRowSelect in DataGrid Pin
Jassim Rahma29-Jun-05 11:52
Jassim Rahma29-Jun-05 11:52 
GeneralRe: FullRowSelect in DataGrid Pin
Hugo Migneron30-Jun-05 3:09
Hugo Migneron30-Jun-05 3:09 
GeneralHeader information in UDP Packet Pin
Hugo Migneron29-Jun-05 9:36
Hugo Migneron29-Jun-05 9:36 
Generalrunning g++ using process.start Pin
thepersonof29-Jun-05 8:31
thepersonof29-Jun-05 8:31 
GeneralRe: running g++ using process.start Pin
Judah Gabriel Himango29-Jun-05 8:44
sponsorJudah Gabriel Himango29-Jun-05 8:44 
GeneralRe: running g++ using process.start Pin
S. Senthil Kumar29-Jun-05 9:02
S. Senthil Kumar29-Jun-05 9:02 
GeneralRe: running g++ using process.start Pin
S. Senthil Kumar29-Jun-05 9:01
S. Senthil Kumar29-Jun-05 9:01 

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.