Click here to Skip to main content
15,912,504 members
Home / Discussions / C#
   

C#

 
AnswerRe: help Pin
SeMartens22-Apr-09 4:39
SeMartens22-Apr-09 4:39 
AnswerRe: help Pin
CPallini22-Apr-09 4:41
mveCPallini22-Apr-09 4:41 
AnswerRe: help Pin
Thomas ST22-Apr-09 4:45
Thomas ST22-Apr-09 4:45 
QuestionObject "type not expected" when using serialization in web services Pin
BASONJS22-Apr-09 4:03
BASONJS22-Apr-09 4:03 
AnswerRe: Object "type not expected" when using serialization in web services Pin
Thomas ST22-Apr-09 4:59
Thomas ST22-Apr-09 4:59 
GeneralRe: Object "type not expected" when using serialization in web services Pin
BASONJS22-Apr-09 5:14
BASONJS22-Apr-09 5:14 
GeneralRe: Object "type not expected" when using serialization in web services Pin
Thomas ST22-Apr-09 20:57
Thomas ST22-Apr-09 20:57 
GeneralRe: Object "type not expected" when using serialization in web services Pin
BASONJS22-Apr-09 23:04
BASONJS22-Apr-09 23:04 
I have done as you suggested and am still getting the same error. The problem now I believe is the way I am serialising the object. I have made a custom class for this:

using System;
using System.Text;

namespace Helper
{
public class Serializer
{
public Serializer()
{

}

///
/// Method to deserialise an object from a string of hex characters
///

/// <param name="hex" />
/// <returns>the object which was deserialised

public Object DeserialiseObject(String hex)
{
System.IO.MemoryStream stream2;
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bformatter2
= new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

byte[] array = HexStringToByteArray(hex);
stream2 = new System.IO.MemoryStream(array);
Object obj = bformatter2.Deserialize(stream2);
stream2.Close();
return obj;
}

///
/// Method to serialise an object into a hex string
///

/// <param name="temp" />
/// <returns>

public string serializeObject(Object temp)
{
//write it to stream
System.IO.MemoryStream stream2 = new System.IO.MemoryStream();
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bformatter2
= new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
bformatter2.Serialize(stream2, temp);
byte[] array = new byte[stream2.Length];
array = stream2.ToArray();
String hex = ByteArrayToHexString(array);
stream2.Close();
return hex;
}

///
/// Helper to change a byte array to a hex string
///

/// <param name="Bytes" />
/// <returns>string of hex characters

private static string ByteArrayToHexString(byte[] Bytes)
{
StringBuilder Result;
string HexAlphabet = "0123456789ABCDEF";

Result = new StringBuilder();

foreach (byte B in Bytes)
{
Result.Append(HexAlphabet[(int)(B >> 4)]);
Result.Append(HexAlphabet[(int)(B & 0xF)]);
}

return Result.ToString();
}

///
/// Helper to change hex string to byte array
///

/// <param name="Hex" />
/// <returns>returns a byte array

private static byte[] HexStringToByteArray(string Hex)
{
byte[] Bytes;
int ByteLength;
string HexValue = "\x0\x1\x2\x3\x4\x5\x6\x7\x8\x9|||||||\xA\xB\xC\xD\xE\xF";

ByteLength = Hex.Length / 2;
Bytes = new byte[ByteLength];

for (int x = 0, i = 0; i < Hex.Length; i += 2, x += 1)
{
Bytes[x] = (byte)(HexValue[Char.ToUpper(Hex[i + 0]) - '0'] << 4);
Bytes[x] |= (byte)(HexValue[Char.ToUpper(Hex[i + 1]) - '0']);
}

return Bytes;
}

}
}
GeneralRe: Object "type not expected" when using serialization in web services Pin
BASONJS23-Apr-09 5:29
BASONJS23-Apr-09 5:29 
Questionproblem with keypress function Pin
MehmetKocc22-Apr-09 3:57
MehmetKocc22-Apr-09 3:57 
AnswerRe: problem with keypress function Pin
musefan22-Apr-09 4:02
musefan22-Apr-09 4:02 
AnswerRe: problem with keypress function Pin
Luc Pattyn22-Apr-09 4:13
sitebuilderLuc Pattyn22-Apr-09 4:13 
AnswerRe: problem with keypress function Pin
DoctorMick22-Apr-09 4:15
DoctorMick22-Apr-09 4:15 
AnswerRe: problem with keypress function Pin
ramz_g22-Apr-09 23:22
ramz_g22-Apr-09 23:22 
QuestionRefreshing Windows Form content / moving the window around Pin
Piratenwichtl200022-Apr-09 3:40
Piratenwichtl200022-Apr-09 3:40 
AnswerRe: Refreshing Windows Form content / moving the window around Pin
musefan22-Apr-09 4:00
musefan22-Apr-09 4:00 
GeneralRe: Refreshing Windows Form content / moving the window around Pin
Piratenwichtl200022-Apr-09 21:24
Piratenwichtl200022-Apr-09 21:24 
QuestionHow can i perform Alt+T operation through programming in c#.net 3.5 Windows application. Pin
Narendra Reddy Vajrala22-Apr-09 3:35
Narendra Reddy Vajrala22-Apr-09 3:35 
AnswerRe: How can i perform Alt+T operation through programming in c#.net 3.5 Windows application. Pin
Henry Minute22-Apr-09 3:49
Henry Minute22-Apr-09 3:49 
GeneralRe: How can i perform Alt+T operation through programming in c#.net 3.5 Windows application. Pin
Narendra Reddy Vajrala22-Apr-09 5:08
Narendra Reddy Vajrala22-Apr-09 5:08 
GeneralRe: How can i perform Alt+T operation through programming in c#.net 3.5 Windows application. Pin
Henry Minute22-Apr-09 5:12
Henry Minute22-Apr-09 5:12 
AnswerRe: How can i perform Alt+T operation through programming in c#.net 3.5 Windows application. Pin
Luc Pattyn22-Apr-09 4:16
sitebuilderLuc Pattyn22-Apr-09 4:16 
Questioncan i rotate a panel and its content Pin
Babita Shivade22-Apr-09 3:00
Babita Shivade22-Apr-09 3:00 
AnswerRe: can i rotate a panel and its content Pin
Dave Kreskowiak22-Apr-09 6:38
mveDave Kreskowiak22-Apr-09 6:38 
Questioni am posting the same question here for reference for u peoples Pin
Hema Bairavan22-Apr-09 2:57
Hema Bairavan22-Apr-09 2:57 

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.