Issue with CodeSnippetFolder

SyntaxEditor for Windows Forms Forum

Posted 18 years ago by Ashton - Developer, Schema Solutions LLC
Avatar
I'm having a weird problem with CodeSnippetFolder. I tried creating a global method to cache the folder and used the following syntax:


                private static CodeSnippetFolder g_Snippets;

        internal static ActiproSoftware.SyntaxEditor.CodeSnippetFolder Snippets
        {
            get
            {
                if (Start.g_Snippets == null)
                    Start.g_Snippets = new ActiproSoftware.SyntaxEditor.CodeSnippetFolder("SQL Snippets", Start.AppPath + "\\Snippets");

                return Start.g_Snippets;
            }
        }

If I use the above code, I get the following error when I call the method to get the snippet folder:

Object reference not set to an instance of an object.

at _6._7()
at _5.OnDisplayed(EventArgs e)
at ActiproSoftware.WinUICore.PopupControl.ShowPopup(Control owner, Boolean activate)
at ActiproSoftware.SyntaxEditor.IntelliPromptCodeSnippets.ShowInsertSnippetPopup(Int32 offset, String labelText, CodeSnippetFolder folder, CodeSnippetTypes type)
at myApp.menuBar_ItemClick(Object sender, EventArgs e) in c:\development\myFile.cs:line 10372
at DevComponents.DotNetBar.DotNetBarManager.AT(BaseItem 384)
at DevComponents.DotNetBar.BaseItem.RaiseClick()
at DevComponents.DotNetBar.BaseItem.InternalMouseUp(MouseEventArgs objArg)
at DevComponents.DotNetBar.PopupItem.InternalMouseUp(MouseEventArgs objArg)
at DevComponents.DotNetBar.ButtonItem.InternalMouseUp(MouseEventArgs objArg)
at DevComponents.DotNetBar.MenuPanel.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.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)

However, if I change the method to the following it works:

        internal static ActiproSoftware.SyntaxEditor.CodeSnippetFolder Snippets
        {
            get
            {
                return new ActiproSoftware.SyntaxEditor.CodeSnippetFolder("SQL Snippets", Start.AppPath + "\\Snippets");
            }
        }
In the code that breaks, the CodeSnippetFolder is a valid object that contains items.

Any ideas?

Thanks,

Comments (3)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
That's odd because we actually cache the folder in the sample project too. Can you tell us how to dupe it in the sample app so we can debug the issue?


Actipro Software Support

Posted 18 years ago by Guy
Avatar
Thank you,

I was having similar issues.

Funny thing I tried code similar to the sample code:

editor.IntelliPrompt.CodeSnippets.ShowInsertSnippetPopup(editor.Caret.Offset, "Insert Snippet:", 
    new CodeSnippetFolder("Root", owner.ApplicationFolder +"\\snippets\\4GL"), CodeSnippetTypes.Expansion);
My application is a MDI form. The form creation and other event handling is done through a non GUI object built from ApplicationContext. This layer manages the main form, all the child forms, dialogs, etc. It also handles other global object suchs a folders and Snippets.

This is the code that did not work.

public string ApplicationPath
{
  get {return Path.GetDirectoryName(Application.ExecutablePath);}
}
public ActiproSoftware.SyntaxEditor.CodeSnippetFolder Snippets
{
  get
  {
    return new ActiproSoftware.SyntaxEditor.CodeSnippetFolder("ROOT", 
      FourJsIdeApplication.ApplicationPath + "\\Snippets\\4GL");
  }
}
Changed the above methods to static and the call to the function changed.

class MainApplication
{
.
.
.

  internal static string ApplicationPath
  {
    get {return Path.GetDirectoryName(Application.ExecutablePath);}
  }

  internal static ActiproSoftware.SyntaxEditor.CodeSnippetFolder Snippets
  {
    get
    {
      return new ActiproSoftware.SyntaxEditor.CodeSnippetFolder("ROOT", 
        MainApplication.ApplicationPath + "\\Snippets\\4GL");
    }
  }
.
.
.
}
The new ShowInsertSnippetPopup

editor.IntelliPrompt.CodeSnippets.ShowInsertSnippetPopup(editor.Caret.Offset, "Insert Snippet:", 
    new CodeSnippetFolder("Root", MainApplication.ApplicationFolder +"\\snippets\\4GL"), CodeSnippetTypes.Expansion);
or

editor.IntelliPrompt.CodeSnippets.ShowInsertSnippetPopup(editor.Caret.Offset, "Insert Snippet:", 
    MainApplication.Snippets, CodeSnippetTypes.Expansion);
Again thank you, this was a show stopper in the evaluation of the product. I can get around the evaluation time bomb dialog box by hitting OK, but this one took a while.

And I hope this helps.

GB

[Modified at 10/22/2005 01:47 AM]
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Can you email us a small sample application that shows the problem? This is something that we'll need to debug and we'd like to get a maintenance release out very soon because we have a lot of other minor feature enhancements (especially for code snippets) ready to go.

Also, if you need an evaluation extension, just send us an email and we'll tell you how. We're happy to help any potential customer extend the evaluation if they need more time.


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.