VB和XML编码(UTF-8)?

时间:2010-01-27 04:24:10

标签: xml

伙计们......我真的需要你的帮助..

我有这个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发送到队列...

请帮助..

1 个答案:

答案 0 :(得分:0)

可以使用encoding-class更改编码。

Dim value As Encoding

value = Encoding.UTF8

有关使用UFT8的更多信息,请参阅here中的MSDN