Posted 19 years ago
by Mike Mason

Hi there,
I'm trying to use the code highlighting engine without using the web control, and looking at the API and other posts around here it seems I should use CodeHighlighterEngine directly. Sadly I haven't been able to get it to work -- it seems to throw a null reference exception somewhere internally.
I think I've probably got the set up wrong and it's not finding the language definition correctly or something, but it's unclear to me what setup steps I need to do. Here's the code that doesn't work right now:The final line throws a null reference inside the GenerateHtmlInline method. I'm also think "Foo" is probably not the unique ID you were looking for...
Any help appreciated,
Mike.
I'm trying to use the code highlighting engine without using the web control, and looking at the API and other posts around here it seems I should use CodeHighlighterEngine directly. Sadly I haven't been able to get it to work -- it seems to throw a null reference exception somewhere internally.
I think I've probably got the set up wrong and it's not finding the language definition correctly or something, but it's unclear to me what setup steps I need to do. Here's the code that doesn't work right now:
string content = "// C Sharp source code here";
SyntaxLanguageConfiguration slConfig = new SyntaxLanguageConfiguration();
slConfig.DefinitionPath = @"C:\temp\CodeHighlighter\Languages";
SyntaxLanguage sLanguage = new SyntaxLanguage("CSharp", false);
CodeHighlighterEngine chEngine = new CodeHighlighterEngine();
string rendered = chEngine.GenerateHtmlInline("Foo", "CSharp", sLanguage);
Any help appreciated,
Mike.