Click here to Skip to main content
15,920,596 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionHow I access messege? Pin
sam_pune14-Mar-05 2:50
sam_pune14-Mar-05 2:50 
AnswerRe: How I access messege? Pin
Dahoolio14-Mar-05 3:09
Dahoolio14-Mar-05 3:09 
AnswerRe: How I access messege? Pin
scottgp14-Mar-05 5:15
professionalscottgp14-Mar-05 5:15 
QuestionHow to search through the database from vb.net? Pin
ADY00714-Mar-05 1:46
ADY00714-Mar-05 1:46 
AnswerRe: How to search through the database from vb.net? Pin
Christian Graus14-Mar-05 14:34
protectorChristian Graus14-Mar-05 14:34 
Generalcustomized drawing a curve Pin
mats_mathai13-Mar-05 23:59
mats_mathai13-Mar-05 23:59 
GeneralWebbrowser control again Pin
mecracked13-Mar-05 23:11
sussmecracked13-Mar-05 23:11 
GeneralDeserialization Troubles Pin
Dahoolio13-Mar-05 22:25
Dahoolio13-Mar-05 22:25 
Hi all!!
Could somebody please tke a look at the the following?
I have been searching an anwser for a de-serialization trouble i am having in my project, however i cannot find a cause as why it should not work..... The project a server listner setup using sockets so i will post both parts of the code
However, the server side file is equal to the listener side received file, I compared both files in Textpad and it says they are byte identical. Also the serialized class is available in both project parts. I tried both soap and binary formatters which both will not work...

ServerSide Code;
<code>
Dim io As MemoryStream = New MemoryStream
'Dim Bf As BinaryFormatter = New BinaryFormatter
Dim Bf As SoapFormatter = New SoapFormatter
SendXML = False
'-- convert file to byte array
Dim Br As New BinaryReader(File.OpenRead(filepath))
Dim bytes() As Byte = Br.ReadBytes(Br.BaseStream.Length)
Br.Close()
'--set filesize of the file buffer
ReDim SdServerSend.File(bytes.Length)
'-- copy array to .file
SdServerSend.File = bytes
'-- serialize class to IO stream
Bf.Serialize(io, SdServerSend)
'-- testpurpose;
Console.WriteLine(System.Text.Encoding.Default.GetString(io.GetBuffer))
'-- writes IO to hdd
Dim BW As New BinaryWriter(File.OpenWrite("C:\PLC\Listener\Received\temptest " & SdServerSend.Type.ToString & " " & EventCounter & ".bin"))
BW.Write(io.GetBuffer, 0, io.Length)
BW.Close()
'-- set io.postion to 0
io.Position = 0
'-- send serialized data to listener
Form1.ClientSocket.Send(io.GetBuffer, io.Length, 0)
</code>


Listener side;
<code>
'-- Receive Message from Current Connection
numbytes = CurSocket.Receive(Buffer, Buffer.Length, 0)
Dim fs As FileStream
Dim filepath As String = "c:\PLC\Listener\Received\Temp " & EventCounter & ".bin"
lstStatus.Items.Insert(lstStatus.Items.Count, "Received Message " & CurRemIp)
lstStatus.SelectedIndex = lstStatus.Items.Count - 1

'-- write this file to HDD location filepath as temp buffer;
Dim BW As New BinaryWriter(File.OpenWrite(filepath))
BW.Write(Buffer, 0, numbytes)
BW.Close()
'-- copy contents of temp.bin into a byte buffer
fs = File.OpenRead(filepath)
Dim SdServerSend As SerialData = New SerialData
Dim bf As SoapFormatter = New SoapFormatter
'Dim Bf As BinaryFormatter = New BinaryFormatter

'-- deserialize memorystream into dsrecv as SerialData
Dim SocketListenerSDRecv As SerialData = CType(Bf.Deserialize(fs), SerialData)
'-- close filestream
fs.Close()
</code>

So the file i receive is temporarily stored on hdd and reread as a bytearray to de-serialize it into memory,
The deserializer turns up with the following error for soap formater:
ParserError. No assembly is attached to the soap formatter a1:http://schemas.microsoft.com/clr/nsassem/C1000Client/C1000Client%2C%20Version%3D1.0.1899.16105%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull

SerialData;
binary formatter errorcould not find assembly version=1.0.1896.29558, culture=neutral, publickeytoken=null
The files in question both on server and listener are identical


either in SOAP;

<code><SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<a1:SerialData id="ref-1" xmlns:a1="http://schemas.microsoft.com/clr/nsassem/C1000Client/C1000Client%2C%20Version%3D1.0.1899.16105%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull">
<PLCname id="ref-3">System001</PLCname>
<Type>EVENT</Type>
<File href="#ref-4"/>
</a1:SerialData>
<SOAP-ENC:Array id="ref-4" xsi:type="SOAP-ENC:base64">77u/PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS1YTUxFVkVOVC54bWwgY3JlYXRlZCBhdCAxNC0zLTIwMDUgMTA6MTY6MTIgb24gUExDIGV2ZW50LS0+DQo8SFdGWE1MVjEgeG1sbnM9Imh0dHA6Ly90ZW1wdXJpLm9yZy9IV0ZYTUxWMS54c2QiPg0KICA8VkVSU0lPTj4wMTwvVkVSU0lPTj4NCiAgPEFNU05FVElEPjE5Mi4xNjguMjU1LjIwNC4xLjE8L0FNU05FVElEPg0KICA8QklOPg0KICAgIDxJRD5UZXN0MTwvSUQ+DQogICAgPFZBTFVFPkZhbHNlPC9WQUxVRT4NCiAgICA8Q0FVU0U+RVZFTlQ8L0NBVVNFPg0KICAgIDxRVUFMSUZZPlZBTElEPC9RVUFMSUZZPg0KICAgIDxUWVBFPk1JTjwvVFlQRT4NCiAgICA8U1RBTVA+MTQtMy0yMDA1IDEwOjE1OjU4PC9TVEFNUD4NCiAgPC9CSU4+DQo8L0hXRlhNTFYxPg==</SOAP-ENC:Array>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope></code>

or in Binaryformatter;
<code>
" ÿÿÿÿ" ' IC1000Client, Version=1.0.1899.16105, Culture=neutral, PublicKeyToken=null" C1000Client.SerialData PLCnameTypeFile"C1000Client.Type' ''  System001üÿÿÿC1000Client.Type" value__ ' "   ¤" '<?xml version="1.0" encoding="utf-8"?>
<!--XMLEVENT.xml created at 14-3-2005 10:18:38 on PLC event-->
<HWFXMLV1 xmlns="http://tempuri.org/HWFXMLV1.xsd">
<VERSION>01</VERSION>
<AMSNETID>192.168.255.204.1.1</AMSNETID>
<BIN>
<ID>Test0</ID>
<VALUE>True</VALUE>
<CAUSE>EVENT</CAUSE>
<QUALIFY>VALID</QUALIFY>
<TYPE>MAX</TYPE>
<STAMP>14-3-2005 10:18:23</STAMP>
</BIN>
</HWFXMLV1>
</code>





If you make something idiotproof, someone else will make a better idiot.....
GeneralAsk for GIS software Pin
nobita3x13-Mar-05 17:38
nobita3x13-Mar-05 17:38 
GeneralRe: Ask for GIS software Pin
Robert Rohde13-Mar-05 19:30
Robert Rohde13-Mar-05 19:30 
GeneralRe: Ask for GIS software Pin
nobita3x13-Mar-05 20:21
nobita3x13-Mar-05 20:21 
GeneralRe: Ask for GIS software Pin
Robert Rohde14-Mar-05 18:51
Robert Rohde14-Mar-05 18:51 
GeneralRe: Ask for GIS software Pin
nobita3x13-Mar-05 19:31
nobita3x13-Mar-05 19:31 
QuestionWhats wrong? Pin
badcredit13-Mar-05 15:21
badcredit13-Mar-05 15:21 
AnswerRe: Whats wrong? Pin
Computer_Guy13-Mar-05 16:16
Computer_Guy13-Mar-05 16:16 
GeneralRe: Whats wrong? Pin
badcredit13-Mar-05 16:28
badcredit13-Mar-05 16:28 
GeneralSpan Between Dates Pin
Computer_Guy13-Mar-05 15:10
Computer_Guy13-Mar-05 15:10 
General<edit>Re: Span Between Dates <edit /> Pin
Edbert P13-Mar-05 18:02
Edbert P13-Mar-05 18:02 
GeneralRe: &lt;edit&gt;Re: Span Between Dates &lt;edit /&gt; Pin
Computer_Guy13-Mar-05 18:10
Computer_Guy13-Mar-05 18:10 
GeneralRe: <edit>Re: Span Between Dates <edit /> Pin
Edbert P13-Mar-05 19:35
Edbert P13-Mar-05 19:35 
GeneralRe: &lt;edit&gt;Re: Span Between Dates &lt;edit /&gt; Pin
Computer_Guy14-Mar-05 2:09
Computer_Guy14-Mar-05 2:09 
GeneralRe: &lt;edit&gt;Re: Span Between Dates &lt;edit /&gt; Pin
Edbert P14-Mar-05 11:25
Edbert P14-Mar-05 11:25 
GeneralRe: &lt;edit&gt;Re: Span Between Dates &lt;edit /&gt; Pin
Computer_Guy14-Mar-05 11:40
Computer_Guy14-Mar-05 11:40 
GeneralRe: &lt;edit&gt;Re: Span Between Dates &lt;edit /&gt; Pin
Edbert P14-Mar-05 12:11
Edbert P14-Mar-05 12:11 
GeneralRe: &lt;edit&gt;Re: Span Between Dates &lt;edit /&gt; Pin
Computer_Guy14-Mar-05 12:46
Computer_Guy14-Mar-05 12:46 

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.