I want to learn the absolute correct way to pass exceptions from Class Library .dll to other .dll or Executable (Form1). I don't receive the actual .dll exception, instead I receive a general try/catch exception from the Form1 attempt to use the .dll. Help!
[Example Summary]
Click a button on Form1 to clear the local Queue without first specifying the Queue name will cause an exception.
Seems to me the the .dll CreateQueue() exception should 'bubble-up' to Form1.
Does this make sense?
Q1. How do I pass the .dll exception to the .exe (MyForm1)?
Q2. How do I pass the .dll exception to another .dll then to .exe (MyForm1)?
[MyForm1.exe]
public static void ClearQueue()
{
msgQueue.QueueName = ""; //intentionally blank for testing purposes
msgQueue.ClearQueue();
}
[MyQueueManager.dll] (referenced by MyForm1.exe)
public static void CreateQueue()
{
try
{
if (MessageQueue.Exists(_queueName))
msgQueue = new MessageQueue(_queueName);
else
msgQueue = MessageQueue.Create(_queueName);
}
catch (MessageQueueException ex)
{
throw new Exception("MsmqManager.MSMQueue.CreateQueue() Exception: ", ex);
}
}
public static void ClearQueue()
{
CreateQueue();
msgQueue.Purge();
}