AdaptiveCards: Incompatibility with bot framework 4.2.0+

Target Platforms

Other

SDK Version

1.4.0

Application Name

all

Problem Description

Since BF was updated to use ANTLR 4.11.1 (in 4.2.0) it is no longer possible to use new AdaptiveCardTemplate(json) in the same project

It fails with this error:

      System.TypeInitializationException: The type initializer for 'AdaptiveCardsTemplateLexer' threw an exception.
       ---> System.MissingMethodException: Method not found: 'Antlr4.Runtime.Atn.ATN Antlr4.Runtime.Atn.ATNDeserializer.Deserialize(Char[])'.
         at AdaptiveCardsTemplateLexer..cctor()
         --- End of inner exception stack trace ---
         at AdaptiveCardsTemplateLexer..ctor(ICharStream input)
         at AdaptiveCards.Templating.AdaptiveCardTemplate..ctor(Object jsonTemplate)

Screenshots

No response

Card JSON

Example, but all fail:

{
    "type": "AdaptiveCard",
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.5",
    "body": [
        {
            "type": "TextBlock",
            "text": "this doesnt work",
            "wrap": true
        }
    ]
}

Sample Code Language

C# (dotnet core)

Sample Code

I have created a repro below:

https://github.com/jamesemann/adaptive-cards-incompatibility

If you dotnet run, you will see:

❯ dotnet run
Unhandled exception. System.TypeInitializationException: The type initializer for 'AdaptiveCardsTemplateLexer' threw an exception.
 ---> System.MissingMethodException: Method not found: 'Antlr4.Runtime.Atn.ATN Antlr4.Runtime.Atn.ATNDeserializer.Deserialize(Char[])'.
   at AdaptiveCardsTemplateLexer..cctor()
   --- End of inner exception stack trace ---
   at AdaptiveCardsTemplateLexer..ctor(ICharStream input)
   at AdaptiveCards.Templating.AdaptiveCardTemplate..ctor(Object jsonTemplate)
   at Repro.DoesItWork.Main() in C:\repos\templatingrepro\Repro\Repro\Program.cs:line 9
   at Repro.DoesItWork.<Main>()

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

it’s released.

Thanks a lot @jwoo-msft

@jamesemann,

Unfortunately, ANTLR cannot be updated to version 4.11.1. The reason is that the template library depends on the AdaptiveExpression library, which in turn relies on ANTLR runtime 4.8.0.

Simply updating ANTLR in the template library alone won’t make it compatible with version 4.11.1, as the AdaptiveExpression library will face the same issue you are currently encountering.

I recommend reaching out to the AdaptiveExpression team to inquire about updating their library to the version you desire. Once the AdaptiveExpression library is updated, we can proceed with updating the template library.

AdaptiveExpressions 4.11.3 on NuGet

Thanks,

Hi @jwoo-msft . The AdpativeExpressions project was updated to use ANTLR 4.11.1 in AdaptiveExpressions 4.20, so both 4.20.0 and 4.20.1 already link to it. See https://www.nuget.org/packages/AdaptiveExpressions/4.20.0. This was the same release of Bot Framework that is causing the incompatibility.

@jamesemann,

I will update SDK to use ANTLR 4.11.1