Posted 18 years ago by Karl Grambow
Avatar
I'm using SyntaxEditor v3.1.210.0 with .NET 1.1 on Windows XP. Using VB.NET

I'm getting a very random exception (see stack trace, below) occurring in a variety of situations but I can never seem to duplicate the problem - which I know doesn't help.

So far I've seen the below exception occur when I have opened a form that contained a SyntaxEditor, when pressing Enter to AutoComplete an IntelliPrompt selection or when selecting a word within SyntaxEditor and subsequently type "@" (without the quotes) so as to replace that word with "@". Note that "@" is a trigger which would have triggered an IntelliPrompt list to be made visible.

The problem is that in all of the above cases repeated attempts to duplicate the issue have failed. Literally, I can go for hundreds of hours without seeing the exception and then all of a sudden, it happens.

The one time I saw this exception when I was running in debug mode, I opted to Break and I got the following message: "No Source Code Available for the Current Location".

I know that the information I've given you really can't help much and the randomness of it makes it pretty impossible to duplicate.

So any help/suggestions you can offer that might help me nail this one done would be really appreciated. This one is starting to drive me crazy.

The only good thing about this is that it is so random that few of my customers are seeing it but eventually they'll start to ask questions, I'm sure.

Thanks,

Karl

Here's the trace:
 
System.NullReferenceException

Stack Trace:
   at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
   at System.Windows.Forms.Control.DefWndProc(Message& m)
   at System.Windows.Forms.Control.WmUpdateUIState(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.ParkingWindow.WndProc(Message& m)
   at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Comments (7)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hmmm... I'm not sure where to start looking for that myself since none of our
code is listed in the stack trace. You said that it only occurs when an IntelliPrompt
selection is made or did you say that it also happens right when the main Form opens
and no IntelliPrompt is used yet?


Actipro Software Support

Posted 18 years ago by Craig Neblett - Elysian Software
Avatar
That's almost guaranteed to be a "painting from a non UI thread" problem. Check to make sure that you don't have any worker threads that could be causing the editor to visuall update itself in any way.

Craig Neblett craig@codersglow.com

Posted 18 years ago by Karl Grambow
Avatar
Thanks for the replies.

In response to Actipro Support:

The exception has cropped up on a couple of occassions when opening a form that had SE on it. And it occurred as the form was opening up so I guess it would have been in the InitializeComponent or OnLoad that it would have happened.

The other time I've seen it happen was when pressing Enter in order to complete a selected item from an IntelliPrompt list. So I pressed Enter, the IntelliPrompt that was currently selected was completed successfully and the excetion occurred.

In response to Craig's suggestion, this might be a possibility.

I have a Timer object on the form and I'm handling the Elapsed event (interval is set to 5 minutes). So every 5 minutes, I'm performing an "auto-save" whereby I save the contents of the open SyntaxEditor. At the moment the auto-save runs the ModificationMarkColor is changed to LimeGreen.

Is it possible that if I'm editing the document at the moment the auto-save runs that this is what is causing the exception? The auto-save normally runs without a problem but perhaps it happens to throw an exception if it coincides with the document being edited at the exact same point in time.

If so this would potentially explain why the exception is so random.

Assuming this is the source of my problem is there a way I could get around it?

I'm not sure this explains the exception that is occurring when I'm opening a form with a SE on it. But that could be unrelated.

Thanks for the input so far.

Karl
Posted 18 years ago by Craig Neblett - Elysian Software
Avatar
Just before you change the color, check the form's InvokeRequired property. If it's true you need to move the code dealing with the editor to a separate method and call it using the Invoke method and a delegate.

[Modified at 06/20/2006 06:55 PM]

Craig Neblett craig@codersglow.com

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Maybe another thing to try is disable the auto-save timer and see if you still get the problem
to show up. If not then you know that is probably the reason for the problem.
But generally timers are on the same thread as the UI (if you are using the Timer control)
so I wouldn't think that it would be an issue.

If you come across a different stack trace, like one with some of our methods in it, please
post it too. That might help narrow down if it is something we are doing.


Actipro Software Support

Posted 18 years ago by Karl Grambow
Avatar
Craig you were spot on.

The form's InvokeRequired property is set to true when the auto-save runs. I guess the Timer isn't running on the same thread as the UI.

I am curious as to why this doesn't cause a problem 99% of the time though. For the most part auto-save works fine and the color changes without any issue even though I am not using the Invoke method and a delegate.

So how come it seems to work (most of the time) even though InvokeRequired is true?

Anyway, I'll implement a solution using Invoke and a delegate and hopefully that will be the end of it. Given the randomness of the problem it could be a long while before I'm certain it is fixed but it does seem like this is the most likely reason.

Thanks for all your help.

Karl
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Excellent advice Craig... thanks for assisting!

Multithreaded situations are sometimes very difficult to debug. You typically have to randomly have everything collide at the same time for you to notice issues. Otherwise things will work as expected until that scenario occurs.


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.