Calling CodeHighlighterEngine from code...

CodeHighlighter for ASP.NET Forum

Posted 18 years ago by David House
Avatar
I have copied one of the examples on the forum, and am having the same problem.

Loading the SyntaxLanguage from XML has produced no change...

        Dim sLanguage As SyntaxLanguage = New SyntaxLanguage("SQL", False)
        SyntaxLanguage.LoadFromXml("H:\Windows\Addins\Templates\ActiproSoftware.SQL.xml", 0)
        Dim chEngine As New CodeHighlighterEngine
        ' chEngine.KeywordLinkingEnabled = True
        ' chEngine.KeywordLinkingTarget = sLanguage.ToString
        Dim text As String = String.Empty
        Dim inText As String = proc.Properties(proc.Properties.Count - 1).Value
        text = chEngine.GenerateHtmlInline("Proc", inText, sLanguage)
I have tried it with and without the commented lines...No change...

Get the following error:

System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="ActiproSoftware.CodeHighlighter.Net20"
StackTrace:
at ActiproSoftware.CodeHighlighter.CodeHighlighterEngine.GenerateHtmlInline(String uniqueID, String code, SyntaxLanguage language)
at DDLWebSiteWriter.ProcContents.WriteProcContentsPage(StoredProcedure proc) in H:\Code\DOTNET2.0\Add-Ins\DBSchemaWizardOld\DDLWebSiteWriter\ProcContents.vb:line 65
at DDLWebSiteWriter.ProcContents.Execute() in H:\Code\DOTNET2.0\Add-Ins\DBSchemaWizardOld\DDLWebSiteWriter\ProcContents.vb:line 118
at DDLWebSiteWriter.SQLWebSiteWriter.Execute() in H:\Code\DOTNET2.0\Add-Ins\DBSchemaWizardOld\DDLWebSiteWriter\SQLWebSiteWriter.vb:line 84
at DBSchemaWizard.ucPage4.WriteWebSite() in H:\Code\DOTNET2.0\Add-Ins\DBSchemaWizardOld\DBSchemaWizard\ucPage4.vb:line 44
at DBSchemaWizard.DBWizard.btnNext_Click(Object sender, EventArgs e) in H:\Code\DOTNET2.0\Add-Ins\DBSchemaWizardOld\DBSchemaWizard\DBWizard.vb:line 134
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.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.Application.Run(Form mainForm)
at DBSchemaWizard.DBWizard.Main() in H:\Code\DOTNET2.0\Add-Ins\DBSchemaWizardOld\DBSchemaWizard\DBWizard.Designer.vb:line 2


The variable inText contains the stored procedure that we are trying to format...

What am I doing wrong?

Comments (1)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Your first line is creating an empty SyntaxLanguage and your second line is doing nothing as you have it. You need to get rid of the "new SyntaxLanguage" part of the first line and move the second line up to be the second half of the first line. That will load the language properly.


Actipro Software Support

The latest build of this product (v4.0.59) was released 13 years ago, which was after the last post in this thread.