I just can't seem to get it -LoadLanguageFromXml

SyntaxEditor for Windows Forms Forum

Posted 12 years ago by David Wier
I've been trying to create a small project, with basic CSS and HTML coloring and intellisense - but I just can't seem to get the 1,2,3s of what it takes.
Since all the menus are dynamically created in the sample, it's really hard to follow the flow of how it's done....

Is there, somewhere, a basic tutorial, on how to get this done with one, two or three languages, with the Syntax Editor?

.txtEdit.Document.LoadLanguageFromXml(filenameBase, 0)
object reference not set to an instance of an object

I double and triple checked - I copied the whole languages subdirectory from the Test app to my Relase and Debug directories, as well as my application directory - just to make totally sure -
the filename base = the exact path and name of the xml language file....


[Modified at 10/15/2006 01:16 AM]

Comments (3)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Hi David,

What happens if you just try the static DynamicSyntaxLanguage.LoadFromXml? Perhaps that will give you more info on why the exception is happening. If you still see it then please post as much info about the exception as possible such as inner exception messages, stack traces, etc.

Our sample project has the HTML sample with CSS and other scripting languages built in. If you have the latest v4.0, you can see how the HtmlDynamicSyntaxLanguage class (which ActiproSoftware.HTML.xml defines as its base SyntaxLanguage class) has code to process "triggers" to do things like auto-complete tags or show an HTML tag member list. You can do more things like that to get you started.

Actipro Software Support

Posted 12 years ago by David Wier
Since I am very new to how this all works, please bear with me and give me a small sample of how it works like that....I can't seem to find an example of how it's used, especially in the autocomplete with tag member list - that's really what I'm looking for. I just basically need a step by step on how it works -

.txtEdit.Document. or .txtEdit + that in any form doesn't work
(.txtEdit is the ID of the SyntaxEditor)
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Hi David,

Well there are several ways to design languages. The easiest is the dynamic language. All the types of languages are described in the documentation by the way.

The sample project includes numerous sample dynamic languages. The Languages/Dynamic/Lexers folder in the C# project contains the XML definition for the lexical parsers of these dynamic languages for both the C# and VB sample projects. These XML definitions tell SyntaxEditor how to syntax highlight.

However sometimes you want to add more programmatic functionality such as outlining or smart indent, etc. So we added a SyntaxLanguageTypeName attribute in the root SyntaxLanguage tag that lets you specify a type/assembly to use as the base DynamicSyntaxLanguage class for the XML definition you are loading.

Take for instance ActiproSoftware.Html.xml... That has this attribute value at the top of it:
SyntaxLanguageTypeName="TestApplication.HtmlDynamicSyntaxLanguage, TestApplication"

That says load the TestApplication.HtmlDynamicSyntaxLanguage class as the base class for the language, and it is found in the TestAssembly assembly.

So go up to the Languages/Dynamic folder. There you can see the HtmlDynamicSyntaxLanguage class. It defines code for outlining and has code to handle "triggers". There is a trigger in ActiproSoftware.Html.xml defined for TagListTrigger when a < char is typed and a trigger for tag auto-complete when > is typed.

HtmlDynamicSyntaxLanguage.OnSyntaxEditorTriggerActivated has the code to process the tab list. And the HtmlDynamicSyntaxLanguage language inherits XmlDynamicSyntaxLanguage (which is in the same folder). That class defines how to process the auto-complete trigger.

Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.