By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,010 Members | 1,266 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,010 IT Pros & Developers. It's quick & easy.

catching Microsoft.JScript.JScriptException

P: n/a
bB
I am calling an external dll (compiled JScript) from within a
try/catch/finally block in a C# program and am unable to catch exceptions
being raised in the JScript dll by having a specific 'JScriptExcepton' catch
block. I can't work out why this is.

If I have a general catch block that catches exceptions of type 'Exception'
and print out the type of the exception, it correctly states that the type
is 'Microsoft.JScript.JScriptException'.

I have worked around the problem by doing a string comparison as follows:

catch (Exception ex)
{
hasErrors = true;

errorString +=
"An unexpected error has been encountered\n" +
"whilst processing the entry for '" +

productPackageItem["Description"] + "':\n\n";

//For some reason, exceptions of type "Microsoft.JScript.JScriptException"
//are not being caught with a seperate catch handler, and a comparison
using
//ex.GetType() against this exception class are also not working. A string
//comparison seems to be the only way of differentiated it...

if (ex.GetType().ToString() == "Microsoft.JScript.JScriptException")
{
errorString += "There is an error in the dimension formula\n\n";
}

errorString += "\"" + ex.Message + "\"";
}

What am I missing?

Tim.
Nov 15 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.