我在C#
中创建了一个DLL,它创建了消息队列和对象并发送了该对象
消息队列。我将创建的DLL的引用添加到另一个应用程序。应用
调试点应用于DLL调用函数时成功运行。但是没有调试点,它就不会将对象发送到消息队列。
DLL函数如下:
public void Enqueue()
{
try
{
this.CreateQueue(); //function that creates queue
Message msg = new Message();
DataTable dtOrd;
if (IsSingleOrder)
{
dtOrd = objDBTrans.funcGetNewOrdSingleDetails(this.DefaultSecurityCode, this.OrderCode, this.CreatedDate);
}
else
{
dtOrd = objDBTrans.funcGetBasketOrdDetails(this.DefaultSecurityCode, this.CreatedDate);
}
for (int iRows = 0; iRows < dtOrd.Rows.Count; iRows++)
{
DataRow drOrd;
drOrd = dtOrd.Rows[iRows];
objEMSOrdMap.funcAssignMapping(drOrd);
msg.Body = objEms;
msg.Label = strFileNamq + "_" + objEms.ClOrdID + " " + DateTime.Now.ToString();
queue.Send(msg);
}
}
catch (Exception ex)
{
}
}
创建队列的DLL函数:
public void CreateQueue()
{
try
{
MessageQueue queue;
queue = new MessageQueue(msgQueue, false); //msgQueue = String containing queue name
}
catch (Exception)
{
}
}
调用DLL函数的应用程序函数:
using EMSMsmqDll;
class EMSMSMQDemo : clsDBConnection
{
public void funcDemo()
{
MSMQService objSer = new MSMQService(); //Class from EMSMsmqDll that creates message queue and object and send that object to message queue
objSer.Enqueue();
}
}