No announcement yet.

[OPEN] [#3696] Regression issue 16.8.2 to 17.2.0

  • Filter
  • Time
  • Show
Clear All
new posts

    [OPEN] [#3696] Regression issue 16.8.2 to 17.2.0

    Our application is an Office JavaScript add-in for Excel. I have identified a regression that exists between Bridge versions 16.8.2 and 17.2.0. I have created a test application that contains only the code required to demonstrate the issue.

    This is some code to count the number of worksheets in a workbook. For anyone not familiar with Office JavaScript development, all calls to Excel are asynchronous and work using a request/response model. With a call to, an execution context is created that can be used by calling JavaScript code to interact with Excel. Requests are loaded into the execution context, and a call to context.sync() will trigger the host browser to interact with the Excel application and resolve all operations (read/write from cells, list worksheet, interact with charts, etc). This code is plain JavaScript and runs independently of Bridge.

    Office.initialize = function (reason) {
    (context) {
            console.log("Listing worksheets");
            let worksheets = context.workbook.worksheets;
            return context.sync().then(function () {
                console.log("worksheets: " + worksheets.items.length);
                return context.sync();
            }).catch(function (e) {
    I also have a Bridge project as part of the solution, which includes the following code in the Main method.

    var x = new List<string>();
    Console.WriteLine("Bridge app started");
    If I host the Office content and Bridge content together in the same test page, the code will execute successfully using Bridge 16.8.2. If I upgrade Bridge to 17.2.0, the Excel code to list the worksheets fails with the following stack trace:

    TypeError: Function expected
       at OSF_DAA_ApiMethodCall$ConstructCallArgs (https://localhost:44396/Scripts/Office/1/excel-win32-16.01.debug.js:2513:4)
       at OSF_DAA_AsyncMethodCall$VerifyAndExtractCall (https://localhost:44396/Scripts/Office/1/excel-win32-16.01.debug.js:2604:3)
       at OSF_DDA_DispIdHost_Facade$InvokeMethod (https://localhost:44396/Scripts/Office/1/excel-win32-16.01.debug.js:3224:4)
       at Anonymous function (https://localhost:44396/Scripts/Office/1/excel-win32-16.01.debug.js:3549:7)
       at Anonymous function (https://localhost:44396/Scripts/Office/1/excel-win32-16.01.debug.js:11758:5)
       at lib$es6$promise$$internal$$initializePromise (https://localhost:44396/Scripts/Office/1/excel-win32-16.01.debug.js:12108:8)
       at lib$es6$promise$promise$$Promise (https://localhost:44396/Scripts/Office/1/excel-win32-16.01.debug.js:12263:8)
       at OfficeJsRequestExecutor.prototype.executeAsync (https://localhost:44396/Scripts/Office/1/excel-win32-16.01.debug.js:11757:4)
       at ClientRequestContext.prototype.syn
    Excel context synchronization depends on promises, and a basic promise implementation is included in the Office.js library. I suspect, but I don’t know for sure, that there was some change in Bridge 17 that now conflicts with the Office.js usage and/or implementation.

    This is a link to a zip file containing versions of the app on each of 16.8.2 and 17.2.0. The zip file includes only the code required to demonstrate the issue, but the file size is approximately 14mb because I have the solution set up to use the debug versions of the Office.js files, which are included for each version of the solution.

    The url for the zip file is:

    The requirements to run the test code are VS 2017 and Excel 2016 on Windows.

    To demonstrate the issue:
    1. Open either the 16.8.2 or the 17.2.0 version of the solution
    2. Set the startup project to be ExcelAddIn
    3. Build and run the project
    4. Examine the JavaScript console output in Visual Studio

    Last edited by fabricio.murta; 2018-08-28 @ 01:00 AM.

    I forgot to mention that the relevant Bridge code is found in ExcelBridge\App.cs and the relevant Excel code is found in ExcelWebApplication\Home\Home.js.



      I tried your solution but I see the error "Excel is not defined" in Home.js


        Microsoft includes an app for Office called Script Lab that allows for testing of code snippets. Are you able to run the snippet titled “Basic API Call”?

        To reproduce:
        1. In Excel 2016, go to the Insert tab and click on ‘Store’
        2. Search for ‘Script Lab’ and install
        3. Switch to the ‘Script Lab’ ribbon tab
        4. Click on ‘Code’
        5. Navigate to ‘Samples’
        6. Select ‘Basic API Call’
        7. Click on the run button in the add-in toolbar and select ‘Run in this pane’
        8. Click on ‘Run code’
        9. You should see cell A1 turn yellow and print the range address to the console output window
        The relevant code including the reference to Excel is:

        async function run() {
            await (context) => {
                const range = context.workbook.getSelectedRange();
                range.format.fill.color = "yellow";
                await context.sync()
                console.log(`The range address was "${range.address}".`);
        Are you able to run this code sample?

        I think this is a better test than creating a new Excel Add-In project. By default, a new project does not include any Excel 2016 specific code.



          I believe that the problem is related to the way that Bridge handles collections. If I modify the definition of array in Array.js to modify the type function, and in the inheritance definition I remove the reference to Array, then the problem I'm experiencing disappears. Further testing is required, but the tests we have performed so far pass successfully.

          To be clear, I actually modify the generated bridge.js file we reference in the application, but the problem is sourced originally from Array.js line 1104.

          If I change:

          result = Bridge.define(name, {
              $inherits: [Array, System.Collections.ICollection, System.ICloneable, System.Collections.Generic.IList$1(t), System.Collections.Generic.IReadOnlyCollection$1(t)],

          result = Bridge.define(name, {
              $inherits: [System.Collections.ICollection, System.ICloneable, System.Collections.Generic.IList$1(t), System.Collections.Generic.IReadOnlyCollection$1(t)],
          then lists continue to work and the problems with Excel disappear.
          Last edited by geoffrey.mcgill; 2018-08-27 @ 02:42 PM.


            Hello @chartnado!

            A pull request was sent with a possible solution for this issue (without breaking somewhere else in Bridge).

            We've logged a GitHub issue under #3696 to track the defect. If you want to take a look on the pull request and provide feedback whether it works for you, that'll be greatly appreciated. It just changes a part of bridge.js so it should be easy for you to apply the change and test without the need of fully building Bridge from sources.

            The pull request is linked to the issue above.


              Thank you very much! That does look like it fixes the problem.


                Thanks for the feedback! We'll proceed with the merge, then.