protected void Button3_Click(object sender, EventArgs e) { try { MessageQueue myQueue = MsmqHelper.CreateQueue(); this.Label1.Text = "成功。"; } catch (Exception ex) { this.Label1.Text = "失败!" + ex.ToString(); } }
public static void ReceiveMessage() { try { MessageQueue myQueue = MsmqHelper.CreateQueue(); myQueue.Formatter = new XmlMessageFormatter(new Type[] { typeof(ItemInfo) }); myQueue.ReceiveCompleted += new ReceiveCompletedEventHandler(MyReceiveCompleted); myQueue.BeginReceive(); } catch (Exception ex) { } }