I have created a DLL in C# which creates message queue and object and send that object to message queue. I added the reference of the created DLL to another application. Application runs successfully when debug point is applied to DLL invoking function. But without debug point, it doesn't send object to message queue.
DLL Funtion as follows :
public void Enqueue()
{
try
{
this.CreateQueue();
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)
{
objError.funLogToAll(ex.Source, ex.Message, ex.GetType().ToString() + "::" + ex.Message, ex.StackTrace, ex.TargetSite.ToString(), ex.GetType().Namespace, ex.ToString(), ex.GetType().Module.FullyQualifiedName);
}
}
DLL function that creates queue :
public void CreateQueue()
{
try
{
MessageQueue queue;
queue = new MessageQueue(msgQueue, false);
}
catch (Exception)
{
objError.funLogToAll(ex.Source, ex.Message, ex.GetType().ToString() + "::" + ex.Message, ex.StackTrace, ex.TargetSite.ToString(), ex.GetType().Namespace, ex.ToString(), ex.GetType().Module.FullyQualifiedName);
}
}
Application function that invoke DLL function :
using EMSMsmqDll;
class EMSMSMQDemo : clsDBConnection
{
public void funcDemo()
{
MSMQService objSer = new MSMQService();
objSer.Enqueue();
}
}