NullReferenceException in DotNet Addon

SyntaxEditor for Windows Forms Forum

Posted 16 years ago by Scott Waletzko
Avatar
I am receiving a System.NullReferenceException that crashes the form that my Syntax Editor is on. It appears to be related to mouse movement over the control - if I do not use the mouse it never occurs. I am not handling any events on the control at all, and am using the following code to set up the control:

this.synMain.Document.Language 
    = new ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage();
this.synMain.Document.AutoCaseCorrectEnabled = false;
Following is the exception information:

Quote:
Message:
Object reference not set to an instance of an object.

Source:
"ActiproSoftware.SyntaxEditor.Addons.DotNet.Net20"

Target Site:
{Void a(ActiproSoftware.SyntaxEditor.Document, ActiproSoftware.SyntaxEditor.Addons.DotNet.Ast.CompilationUnit, ActiproSoftware.SyntaxEditor.Addons.DotNet.Dom.DotNetProjectResolver)}

Stack Trace:
at ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpContext.a(Document A_0, CompilationUnit A_1, DotNetProjectResolver A_2)
at ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpContext.GetContextAtOffset(Document document, Int32 offset, CompilationUnit compilationUnit, DotNetProjectResolver projectResolver)
at ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage.GetContext(SyntaxEditor syntaxEditor, Int32 offset, Boolean beforeOffset, Boolean forParameterInfo)
at ActiproSoftware.SyntaxEditor.Addons.DotNet.Dom.DotNetSyntaxLanguage.a(DotNetLanguage A_0, SyntaxEditor A_1, Int32& A_2)
at ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage.OnSyntaxEditorViewMouseHover(SyntaxEditor syntaxEditor, EditorViewMouseEventArgs e)
at ActiproSoftware.SyntaxEditor.SyntaxLanguage.a(SyntaxEditor A_0, EditorViewMouseEventArgs A_1)
at ActiproSoftware.SyntaxEditor.SyntaxEditor.b(EditorViewMouseEventArgs A_0)
at ActiproSoftware.SyntaxEditor.EditorView.OnMouseHover(MouseEventArgs e)
at ActiproSoftware.WinUICore.UIElement.ActiproSoftware.WinUICore.IInputElement.RaiseMouseHoverEvent(MouseEventArgs e)
at ActiproSoftware.WinUICore.UIControl.OnMouseHover(EventArgs e)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at ActiproSoftware.SyntaxEditor.SyntaxEditor.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
at [NAMESPACE REMOVED].CodeEditor.EditValue(ITypeDescriptorContext context, IServiceProvider provider, Object value) in [PATH REMOVED]\CodeEditor.cs:line 29


Clearly it's something that I cannot fix or handle myself - I am not handling any events for the control and the error is occuring within the control's assembly. Please help, I need to start using this control in a production application and cannot deploy it with this bug!

Thanks in advance,

Scott

[Modified at 10/10/2007 12:47 PM]

Comments (6)

Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Scott,

Can you try it in the latest build to see if it is still there. And if it is, please email over a small sample project that shows it happening and we'll get it resolved for the next maintenance release and give you a workaround for now. Thanks!

[Modified at 10/10/2007 02:18 PM]


Actipro Software Support

Posted 16 years ago by Scott Waletzko
Avatar
It would appear that the problem has been resolved in the latest build - my apologies for not testing that sooner, but I thought I had the most recent version already.

Thanks!
Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
No problem, I thought it sounded familiar and am glad it's already fixed for you.


Actipro Software Support

Posted 16 years ago by Bart Read - Red Gate Software Ltd
Avatar
Hi there,


Regrettably this exception is still occurring. We'd been experiencing this problem for a while, and so I searched the forums and found this very thread, which made me upgrade to the latest version, which at the time was 4.0.274.0. I've just managed to reproduce it now:

03 Jul 2008 16:42:55.149 [10] ERROR RedGate.Profiler.UI.Ignition - Object reference not set to an instance of an object.
03 Jul 2008 16:42:55.149 [10] ERROR RedGate.Profiler.UI.Ignition - System.NullReferenceException
03 Jul 2008 16:42:55.196 [10] ERROR RedGate.Profiler.UI.Ignition - at ActiproSoftware.SyntaxEditor.Addons.DotNet.Context.DotNetContext.a(DotNetProjectResolver A_0, IDomType A_1, Int32 A_2, Boolean A_3)
at ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpContext.a(Document A_0, CompilationUnit A_1, DotNetProjectResolver A_2)
at ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpContext.GetContextAtOffset(Document document, Int32 offset, CompilationUnit compilationUnit, DotNetProjectResolver projectResolver)
at ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage.GetContext(SyntaxEditor syntaxEditor, Int32 offset, Boolean beforeOffset, Boolean forParameterInfo)
at ActiproSoftware.SyntaxEditor.Addons.DotNet.Dom.DotNetSyntaxLanguage.a(DotNetLanguage A_0, SyntaxEditor A_1, Int32& A_2)
at ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage.OnSyntaxEditorViewMouseHover(SyntaxEditor syntaxEditor, EditorViewMouseEventArgs e)
at ActiproSoftware.SyntaxEditor.SyntaxLanguage.a(SyntaxEditor A_0, EditorViewMouseEventArgs A_1)
at ActiproSoftware.SyntaxEditor.SyntaxEditor.b(EditorViewMouseEventArgs A_0)
at ActiproSoftware.SyntaxEditor.EditorView.OnMouseHover(MouseEventArgs e)
at ActiproSoftware.WinUICore.UIElement.ActiproSoftware.WinUICore.IInputElement.RaiseMouseHoverEvent(MouseEventArgs e)
at ActiproSoftware.WinUICore.UIControl.OnMouseHover(EventArgs e)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at ActiproSoftware.SyntaxEditor.SyntaxEditor.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


It mainly seems to occur when you hover over, click on or highlight an indexer, or a parameter to an indexer. We have the semantic parser service turned on because we are adding click navigation. It doesn't happen 100% of the time, but it happens enough to be extremely problematic. Incidentally I should point out that our click navigation itself makes no difference to the incidence of this bug: you can completely remove the code and the exception still occurs.

It may also be that this bug has a side-effect in that our click navigation should allow you to navigate to any method that has been executed by clicking on its name in the source view, however a lot of the time it seems not to recognise the method names (this includes constructors, property accesses, etc), so we're now left wondering if this is a side effect of this problem causing the AST to be corrupted or rendered incomplete.

Any help you can offer would be gratefully received.


Many thanks,
Bart

[Modified at 07/03/2008 10:53 AM]
Posted 16 years ago by Bart Read - Red Gate Software Ltd
Avatar
Whoops, I'd meant to give some additional system details, just in case they're useful:

Windows XP SP2
.NET 2.0
VS 2005 Team Edition for Software Developers
4GB RAM
SyntaxEditor 4.0.274.0 + corresponding .NET language add-ons for VB and C#


Thanks,
Bart
Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Bart,

Based on that stack trace you should be able to duplicate it easily once you have it happen. Hovering over the same token in the same document for which this exception occurs should reliably make it happen every time you hover over that token, since it is calling the GetContext code from that point per your stack trace.

Once you are able to repro it in your app this way, please try and load your document text in our .NET Reflection QuickStart. You may also need to add some references to your custom assemblies in that QuickStart via the Add Reference button to make it mimic what is happening in your application. Then once you get there, email us the assemblies needed to repro it along with the code and we can debug it.

It may have something to do with the assemblies you have loaded for reflection so be sure to load the same ones up when trying to repro.

If you would rather, just make a simple project that repros it and email that over. We could work on that as well.


Actipro Software Support

The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.