【问题标题】:Send message to SQL Server message queue from C# Win CE从 C# Win CE 向 SQL Server 消息队列发送消息
【发布时间】:2013-01-16 18:56:43
【问题描述】:

我在 SQL Server ITSERVER 上的数据库 cja 中有一个名为 log_line_queue 的队列。

我有一个在移动设备上运行的 C# Win CE 应用程序。我想从这个应用程序向 log_line_queue 发送一条消息。

这是我目前的代码:

var myQueue = new System.Messaging.MessageQueue("FormatName:Direct=OS:itserver\\private$\\dbo.cja.log_line_queue");

myQueue.Send("My Message Data.", MessageQueueTransactionType.Automatic);

结果

System.Messaging.MessageQueueException: Message Queue service is not available.
   at System.Messaging.MessageQueue.MQCacheableInfo.get_WriteHandle()
   at System.Messaging.MessageQueue.StaleSafeSendMessage(MQPROPS properties, IntPtr transaction)
   at System.Messaging.MessageQueue.SendInternal(Object obj, MessageQueueTransactionType transactionType)
   at System.Messaging.MessageQueue.Send(Object obj, MessageQueueTransactionType transactionType)
   at cjaTest1.MessageQueue.FrmSendToQueue.button1_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam)
   at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
   at Microsoft.AGL.Forms.EVL.EnterModalDialog(IntPtr hwnModal)
   at System.Windows.Forms.Form.ShowDialog()
   at cjaTest1.FrmMainForm.button9_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam)
   at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
   at Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
   at System.Windows.Forms.Application.Run(Form fm)
   at cjaTest1.Program.Main()

我确定我做错了很多事情。欢迎提出建议。

【问题讨论】:

    标签: c# sql-server windows-ce message-queue


    【解决方案1】:

    System.Messaging.MessageQueue 用于与MSMQ 交互。 A queue called log_line_queue in database cja on SQL Server ITSERVER 是表或 Service Broker 队列。这是苹果和橘子,MSMQ 与 SQL Server 无关。要将消息发送到 SQL Server 队列,您必须使用 SEND T-SQL 动词,并且您必须连接到 SQL Server 实例。

    【讨论】:

    • 谢谢,这解释了很多。
    猜你喜欢
    • 1970-01-01
    • 2010-10-21
    • 1970-01-01
    • 2020-04-05
    • 1970-01-01
    • 2013-05-22
    • 1970-01-01
    • 1970-01-01
    • 2011-05-22
    相关资源
    最近更新 更多