Click here to Skip to main content
15,917,473 members
Home / Discussions / C#
   

C#

 
AnswerRe: character postion replacemenet Pin
Gonzalo Cao17-Aug-10 23:51
Gonzalo Cao17-Aug-10 23:51 
GeneralRe: character postion replacemenet Pin
ps_prakash0218-Aug-10 4:27
ps_prakash0218-Aug-10 4:27 
QuestionDataSet does not support System.Nullable<> Pin
treuveni17-Aug-10 23:24
treuveni17-Aug-10 23:24 
AnswerRe: DataSet does not support System.Nullable Pin
Bernhard Hiller18-Aug-10 4:24
Bernhard Hiller18-Aug-10 4:24 
AnswerRe: DataSet does not support System.Nullable Pin
Madmaximus7-Jul-11 4:48
Madmaximus7-Jul-11 4:48 
QuestionSD Card Pin
dataminers17-Aug-10 22:21
dataminers17-Aug-10 22:21 
AnswerRe: SD Card Pin
R. Giskard Reventlov17-Aug-10 22:32
R. Giskard Reventlov17-Aug-10 22:32 
AnswerRe: SD Card Pin
Thomas Krojer18-Aug-10 1:25
Thomas Krojer18-Aug-10 1:25 
QuestionBit Shifting problem Pin
norjali17-Aug-10 21:15
norjali17-Aug-10 21:15 
AnswerRe: Bit Shifting problem Pin
DaveyM6917-Aug-10 21:25
professionalDaveyM6917-Aug-10 21:25 
GeneralRe: Bit Shifting problem Pin
norjali17-Aug-10 21:28
norjali17-Aug-10 21:28 
AnswerRe: Bit Shifting problem Pin
Richard MacCutchan17-Aug-10 21:26
mveRichard MacCutchan17-Aug-10 21:26 
GeneralRe: Bit Shifting problem Pin
norjali17-Aug-10 21:30
norjali17-Aug-10 21:30 
GeneralRe: Bit Shifting problem Pin
norjali17-Aug-10 21:53
norjali17-Aug-10 21:53 
GeneralRe: Bit Shifting problem Pin
Richard MacCutchan17-Aug-10 22:18
mveRichard MacCutchan17-Aug-10 22:18 
QuestionDataadapter and datasets issue Pin
maephisto00717-Aug-10 20:44
maephisto00717-Aug-10 20:44 
Questioncache the name using input param.. Pin
A.Machan Kachan17-Aug-10 17:56
A.Machan Kachan17-Aug-10 17:56 
QuestionHow to convert any object to byte[] without marking it Serializable or DataContract? Pin
1eyhk117-Aug-10 16:35
1eyhk117-Aug-10 16:35 
AnswerRe: How to convert any object to byte[] without marking it Serializable or DataContract? Pin
Gonzalo Cao17-Aug-10 20:56
Gonzalo Cao17-Aug-10 20:56 
GeneralRe: How to convert any object to byte[] without marking it Serializable or DataContract? Pin
1eyhk118-Aug-10 1:51
1eyhk118-Aug-10 1:51 
GeneralReverse Pin
1eyhk118-Aug-10 16:19
1eyhk118-Aug-10 16:19 
GeneralRe: Reverse Pin
Gonzalo Cao18-Aug-10 20:18
Gonzalo Cao18-Aug-10 20:18 
GeneralRe: Reverse Pin
1eyhk118-Aug-10 21:43
1eyhk118-Aug-10 21:43 
GeneralRe: Reverse Pin
Gonzalo Cao18-Aug-10 21:44
Gonzalo Cao18-Aug-10 21:44 
GeneralWokring now, atttempts: from interop to BinaryFormatter to DataContractSerializer - still need to see MyAccount[] Pin
1eyhk120-Aug-10 19:33
1eyhk120-Aug-10 19:33 
Oh bummer
<br />
{"Type 'XXXXX.MyAccount' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed."}<br />


I suspect this is because MyAccount is actually a complex hierarchy containing a child collection...
<br />
class MyAccount<br />
{<br />
...<br />
public List&lt;Invoicesgt; GroupList;<br />
}<br />

Eekkk... I was going to wire down an array of accounts (i.e. MyAccount[]) but now can't even wire down one single MyAccount... I desparation I tried this:
<br />
 using (System.IO.MemoryStream stream = new System.IO.MemoryStream())<br />
{<br />
	BinaryFormatter formatter = new BinaryFormatter();<br />
	formatter.Serialize(stream, result);<br />
	byte[] BinAcct = stream.ToArray());<br />
}<br />


But even then I ran into runtime exception, complaint was that class is not marked serializable (Although marked DataContract), looks like I got lucky with
<br />
DataContractSerializer dataContractSerializer = new DataContractSerializer(Acct.GetType());<br />
using (MemoryStream memoryStream = new MemoryStream())<br />
{<br />
dataContractSerializer.WriteObject(memoryStream, Acct);<br />
btAccountSet = new byte[memoryStream.Length];<br />
Array.Copy(memoryStream.GetBuffer(), btAccountSet, btAccountSet.Length);<br />
}<br />

This finally get the job done (only serialization part, still stuck during deserialization).
<br />
1. Serialize side:<br />
DataContractSerializer serial = new DataContractSerializer(Acct.GetType());<br />
using (MemoryStream memoryStream = new MemoryStream())<br />
{<br />
	serial.WriteObject(memoryStream, oAcct);<br />
	btPayload = new byte[memoryStream.Length];<br />
	Array.Copy(memoryStream.GetBuffer(), btPayload, btPayload.Length);<br />
}<br />
                <br />
2. Deserialize side:			<br />
byte[] raw = (byte[]) GetPayload();<br />
serial = new DataContractSerializer(typeof(MyAccount));<br />
using (MemoryStream memoryStream = new MemoryStream(raw))<br />
{<br />
	memoryStream.Seek(0, SeekOrigin.Begin);<br />
	oAcct = (MyAccount) serial.ReadObject(memoryStream);<br />
}<br />


So, all good sending a single object, but still need to attempt sending/serializing a list of MyAccount (with subclasses)

Thanks

modified on Saturday, August 21, 2010 1:46 AM

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.