Using a newer Antlr3 runtime version

SyntaxEditor for WPF Forum

Posted 10 years ago by Arno Rouschen - Statistics Netherlands
Version: 9.1.0505
Avatar
Hi,

We are currently experimenting with your WPF syntax editor. We have our own Antlr based language that we want to integrate into the syntax editor. However when we want to use this language, then the call to language.RegisterService fails. This is probably because our parser and lexer are based on a newer version of the antlr3.runtime. We are using version 3.1.3.27258, while your example is using version 3.1.2.41038.

What have we done so far?

We have taken your Antlr Calc language example and instead of the AntlrCalc parser we just have referenced our parser and lexer objects. Then we want to register the language, just as in your example:

SyntaxLanguage language = new SyntaxLanguage("BlaiseSQL");
            
language.RegisterService<IParser>(
    new AntlrParser(language.Key, 
        typeof(BlaiseSQLLexer), 
        typeof(BlaiseSQLParser), 
        ""
        ));

We also have tried to use the newer antlr3.runtime.dll (version 3.1.3.27258) instead of the one which is originally referenced in your AntlrCalc example program (version 3.1.2.41038) without changing anything further, but then we get exactly the same error when we call language.RegisterService.

Is there something that we can do to make the newer antlr3.runtime version work?

Thanks,
Arno Rouschen

Comments (12)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Arno,

We've updated the ANTLR build to 3.1.3 for the upcoming WPF Studio maintenance release. The maintenance release should be out sometime in the next couple weeks.

But regardless I noticed that you had an empty string for the root default parser method name. That must be filled in with the root non-terminal name. In our calc example, it is "expr" which is the expression rule. If you set that appropriately for your language, perhaps it will work for you.


Actipro Software Support

Posted 10 years ago by Arno Rouschen - Statistics Netherlands
Avatar
Thank you for your recommendation. We have tried to specify the default parser name, but that didn't help. We are still getting the error message.

We will wait for the next maintenance release.
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
What specifically is the error message?


Actipro Software Support

Posted 10 years ago by Arno Rouschen - Statistics Netherlands
Avatar
The error message is:

{"Cannot create instance of 'MainWindow' defined in assembly 'AntlrIntegration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error in markup file 'AntlrIntegration/MainWindow.xaml' Line 1 Position 9."}

The MainWindow cannot be constructed from the XAML, because in the MainWindow's constructor there is a call to language.RegisterService.

When I leave out this statement then the MainWindow is constructed and displayed.

You can reproduce the problem by referencing the 3.1.3 antlr3.runtime.dll instead of the 3.1.2 version in your AntlrIntegration example.

Arno
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
That exception message is ambiguous though and just wraps the real cause of the problem here. Run it again and when the exception occurs, drill down all the way into the inner exceptions, find the innermost one, and tell us what that says.


Actipro Software Support

Posted 10 years ago by Arno Rouschen - Statistics Netherlands
Avatar
The most inner exception says:

{"Could not load file or assembly 'Antlr3.Runtime, Version=3.1.2.41038, Culture=neutral, PublicKeyToken=3a9cab8f8d22bfb7' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"Antlr3.Runtime, Version=3.1.2.41038, Culture=neutral, PublicKeyToken=3a9cab8f8d22bfb7"}

Message: "Could not load file or assembly 'Antlr3.Runtime, Version=3.1.2.41038, Culture=neutral, PublicKeyToken=3a9cab8f8d22bfb7' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"

Source: "ActiproSoftware.Text.Addons.Antlr.Net20"

StackTrace: " at ActiproSoftware.Text.Parsing.Implementation.AntlrParser..ctor(String key, Type coreLexerType, Type coreParserType, String defaultParserMethodName)\r\n at ActiproSoftware.Windows.AntlrIntegration.MainWindow..ctor() in C:\\Users\\aron.TMO\\Documents\\Actipro Software\\WPFStudio\\v9.1.0505\\AntlrIntegration\\AntlrIntegration\\MainWindow.xaml.cs:line 31"

Seems that there is a specific version of the antlr3.runtime needed, in this case the one that you ship with your example. Maybe it is possible to set specific version to false in your projects.

By the way: Thank you for your effort
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Yes that's definitely it then. I checked and both the build 505 release and the next build code we have here have Specific Version = false in the project. I wonder if you can somehow reroute the assembly using something like this:
http://msdn.microsoft.com/en-us/library/7wd6ex19.aspx

Regardless though our next build will update to 3.1.3.


Actipro Software Support

Posted 10 years ago by Arno Rouschen - Statistics Netherlands
Avatar
Hi.

I didn't succeed in rerouting the assembly to another version. Meanwhile I installed build 507 which originally references antlr3 runtime 3.1.3.42154, which is a newer version than our lexer and parser is based on. If I reference the antlr3 runtime version that we use (3.1.3.27258) then we get the following error message while building the example project:

c:\Program Files (x86)\Actipro Software\WPFStudio\v9.1.0507\Assemblies\ActiproSoftware.Text.Addons.Antlr.Net20.dll : error CS1705: Assembly 'ActiproSoftware.Text.Addons.Antlr.Net20, Version=9.1.507.0, Culture=neutral, PublicKeyToken=36ff2196ab5654b9' uses 'Antlr3.Runtime, Version=3.1.3.42154, Culture=neutral, PublicKeyToken=3a9cab8f8d22bfb7' which has a higher version than referenced assembly 'Antlr3.Runtime, Version=3.1.3.27258, Culture=neutral, PublicKeyToken=3a9cab8f8d22bfb7'

It seems that the ActiproSoftware.Text.Addons.Antlr.Net20.dll still needs a specific version of the antlr3 runtime dll.
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Arno,

We checked again and do have Specific Version = false in the reference to Antlr.Runtime. Is it possible for you to update to the newer 3.1.3 build?


Actipro Software Support

Posted 8 years ago by Robert A. McCarter
Avatar
I'm using version 3.3.3.8388 and when I try and use the ANTLR library I get:

{System.IO.FileLoadException: Could not load file or assembly
'Antlr3.Runtime, Version=3.1.3.42154, Culture=neutral, PublicKeyToken=3a9cab8f8d22bfb7'
or one of its dependencies.
The located assembly's manifest definition does not match
the assembly reference. (Exception from HRESULT: 0x80131040)


Any chance that you could release the source code for this component so that we can compile it against any version we want?

This is very frustrating to have developed a large ANTLR based grammar, just to have this prevent me from using SyntaxEditor to it's fullest.

Robert
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Robert,

We had sent you a private email back on the 29th to ask some questions but didn't get a reply. If you need us to resend it, please let us know. We'd like to get your thoughts on it ASAP since we have a release coming up soon.


Actipro Software Support

Posted 8 years ago by Robert A. McCarter
Avatar
I received it, but haven't had time to investigate.
I'll try and respond tonight.
The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.