2010-01-27 64 views
0

家伙...我真的需要你的帮助..VB和XML编码(UTF-8)?

我有这样的VB代码,我将发送一个文本框中键入MSMQ值...

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click 
    Dim mq As MessageQueue 
    'Dim format As XmlMessageFormatter 
    Dim msg As Message 
    'Dim dec As XmlDeclaration 

    Try 
     msg = New Message 
     msg.Priority = MessagePriority.Normal 

     If Not (MessageQueue.Exists(".\Private$\toNavision")) Then 
      mq = MessageQueue.Create(".\Private$\toNavision") 

     Else 
      mq = New MessageQueue(".\Private$\toNavision") 

     End If 
     msg.Label = "Navision MSMQ-BA" 
     msg.Body = TextBox1.Text 

     mq.Send(msg) 
     Label1.Text = "Message sent." 

    Catch ex As MessageQueueException 
     Label1.Text = ("MSMQ Error: " + ex.ToString()) 

    Catch ex As Exception 
     Label2.Text = ("Error: " + ex.ToString()) 

    Finally 
     mq.Close() 

    End Try 

End Sub 

,结果是成功的。 ..我可以看到队列中的消息...但我不确定XML编码...我需要以UTF-8发送消息,此外我无法弄清楚如何发送那些消息是UTF-8进入队列...

请帮忙..

回答

0

T他可以使用编码类来修改Encoding。

Dim value As Encoding 

value = Encoding.UTF8 

更多关于使用与UFT8可以读取在MSDNhere