This project is read-only.

First change exception when set ConfigurationManager.Language to String.Empty

Apr 21, 2010 at 1:08 AM

I made my own lexer and it's working well in it's current state but there is something that is bothering me.  By following the example, the configuration manager language is set to String.Emtpy.  When this is done (or even ""), this message is thrown in the ouput window:

A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll

If I don't set this to an empty string, I don't have the same behavior for default fonts. For now I don't see any other issue but I don't like that message. What could cause that error?

Any information on the subject will be appreciated.

Apr 23, 2010 at 1:26 AM

A first chance exception message gets written to the Visual Studio Output window when the debugger is given the first chance to see/handle the exception (hence the name). If the debugger is not configured to stop on such an exception then execution will continue. In this case the exception is being caught in code and so execution will continue. The source of your Output window message comes from this block of code in the ConfigurationManager:

	Enum.Parse(typeof(Lexer), _language, true);

	//	If we made it here, the language matches one of
	//	the lexer names, just use that.
	s = _language;
catch (ArgumentException) 
	//	No match, oh well. Don't set the lexer.

As you can see there is an attempt to match the string passed to ConfigurationManager.Lanaguage property to the Lexer enumeration. Trying to parse an empty string is what causes the exception. You can also see that it's currently being swallowed -- obviously not a good practice and a piece of code that should be rewritten to look for empty/null strings before attempting to parse. I'll put it on my to-do list, but CodePlex also makes it very easy to submit a patch yourself. :)

As a side note, it's easy to determine the source of first chance exceptions in Visual Studio by setting a breakpoint on an exception. You can do that by opening the Exception dialog from the Debug -> Exceptions menu item. Place a check in the "Thrown" column of the System.ArgumentException exception and your debugger will stop anytime one of these types of exceptions occurs again.





May 11, 2010 at 6:45 AM
Edited May 11, 2010 at 6:51 AM


Hi Jacob,

sorry for the late reply, I was quite busy and didn't touch any scintilla related code for my editor for a few weeks.

It's good to know that it's a non issue and learned at the same time what to do with those exception. I was using the DLL directly, don't know if it does make a difference for this option in VS.  I will try the option once I have a chance.

I can't wait to see the component to be more .net like. In some case, I have to fall back on the native interface or wanting options that are not available yet like setting objects on the auto complete list, images instead of XPM(?) etc.  Some online help for the function will be great in the future since referring back to the original scintilla doc is often cryptic.  I didn't found yet if you can intercept the selected index for an auto-complete item or not from or native interface. This give me the impression that there is no such option.  I hope I can figure that one someday since I want to show some tooltip help when you select a specific item in the list like VS/Eclipse.

Thank you again for the information.