Chris, I append some code below:
try
{
throw new Exception ("Runtime error-handling simulation.");
}
catch (Exception MyEx)
{
string dm = "Unexpected error in " + MyEx.TargetSite.Module.Name.ToUpper() + " with " + MyEx.TargetSite.Name;
System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(MyEx, true);
dm += " at line " + trace.GetFrame(0).GetFileLineNumber() + " column " + trace.GetFrame(0).GetFileColumnNumber();
dm += ".\r\n" + MyEx.Message;
MessageBox.Show(dm,"C# Diagnostic Message");
}
Notes:
1. Your code should go within the try block; in the sample above, I am generating an error arbitrarily.
2. I am using MessageBox.Show; since you are developing a class library, you will need to add a reference to System.Windows.Forms to your project ( ... perhaps just during the debugging phase?) or circumvent this by writing the message, dm, to a public property in your class such that it can be queried by the client you are using to test the class.
Another approach:
a. In Project Properties| Debug | select "Start External Program" and specify your client application.
b. On any (suspect line) press F9.
c. Run the Server (i.e. your class library); it will launch the client from which you can trigger the code in the server to run and it will stop on all F9 lines in the server code.
d. Then Press F11 to step through the code: this may isolate the location/nature and source of the error.