Click here to Skip to main content
15,885,673 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 :

C#
public void Enqueue()
{
    try
    {
        this.CreateQueue(); //fuction 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)
    {
           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 :

C#
public void CreateQueue()
{
    try
    {
        MessageQueue queue;
        queue = new MessageQueue(msgQueue, false); //msgQueue = String containing queue name          
    }
    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 :
C#



C#
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();
    }
}
Posted
Updated 17-Feb-14 18:57pm
v2

1 solution

You have no idea if your application is throwing any exceptions that would indicate an issue. What you are doing here is swallowing exceptions - only in the most extreme cases, and only if you really, really know what you are doing, should you have an empty catch block. Anything could be going wrong in your code but you'll have no idea because you aren't logging anything. If you must catch the exception, write it out to a log file somewhere so that you can analyse it later on.
 
Share this answer
 
Comments
vishvesh raval 18-Feb-14 1:02am    
i have edited the question and have added the function that catches exception in catch block.The above code runs successfully and didn't log any error but with break point it sends message to queue with invoking of dll functions.But without breakpoint the message dont get placed in meessage queue.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900