hello all...
I'm experiencing a truly bizarre problem... i think i figured out a work around, but I thought i'd post this just in case there was something I was missing...
I have a fairly good sized application running a couple instantiations of the editor. ASP.net 1.1. I instantiate the editor programmatically, and set autoconfigure to none ... as in:
CuteEditor.Editor editor = new CuteEditor.Editor();
editor.AutoConfigure = AutoConfigure.None;
The problem, is that if I set a breakpoint at the second line, many of the properties have null references!!!
Unfortunately, I cannot repro this with the CuteDemo, which comes with the distribution.
I have a screenshot of the debugger, showing a couple of the null reference exceptions, if you are interested.
The following editor properties are all null immediately after editor instantiation:
ClientID
FrameId
ToolBarID
ToolControls
The thing is, the exceptions are continuable. If, in the 'immediate' window of the debugger, you look at 'editor.ToolControls', the first time it spits out the ToolControls object, the first line will be a notification of a null reference exception (with the rest of the object dumped just fine). The second time you look at the object, it dumps the entire object with no problem.
I found it because right after the instantiation, I try to insert a couple of custom editor buttons. The first thing I did to do this was to get the position of a button that was already there from the ToolControls Collection. as follows:
int pos= editor.ToolControls.IndexOf("insertcustombutonhere") + 1;
StringBuilder oString = new StringBuilder();
When I just run the program, it would give me a yellow screen, indicating that I couldn't get editor.ToolControls.IndexOf, because the object reference was null. Whenever I put a breakpoint at 'int pos=...', and inspected the editor and toolControls object, everything seemed fine, and I could continue with no problems, and no yellow screen. HOWEVER, whenever I would put a breakpoint at the next line, I would get a yellow screen from the preceding line!!!
My work around is to instantiate the ToolControls object within a try/catch, catch the exception and then just go on... like so:
string EMSG = null;
try
{
CuteEditor.ToolControlCollecton coll = editor.ToolControls;
}
catch (Exception eCutesoft)
{
EMSG = "I caught an exception!!!... " + eCutesoft.Message;
}
int pos= editor.ToolControls.IndexOf("insertcustombutonhere") + 1;
StringBuilder oString = new StringBuilder();
I know that the exception is being thrown, because I can set a breakpoint at 'EMSG=...', and it always gets there, and the eCuteSoft.Message is always... null reference exception.
So, my question is: has anyone ever seen this before? Is there something I should do to load the object, or maybe ensure the object's initialization?
specifics:
windows xp, sp2
.net framework v 1.1.4322
ms dev environment 2003, v 7.1.3088