Announcement

Collapse
No announcement yet.

Bridge Console - Cannot read property '$initialize' of undefined

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bridge Console - Cannot read property '$initialize' of undefined

    Today, while continuing coding, new window open in chrome call Bridge Console, as in FireFox:

    Click image for larger version

Name:	Screenshot_4.png
Views:	1
Size:	16.5 KB
ID:	2758


    What is that?
    "Start" i write throw my code using Console.WriteLine("Start"); but the Exception is new! it never show, i don´t now what to do, i don´t have any to give that Exception.
    I have in .json config "combineScripts": true

    and an external class library that have some class. I think this start to show after i add Bridge.jQuery2 but not sure.

    Any sugestions?


  • #2
    Found the issue:

    JS:
    addColumn: function (name) {
    if (this._columns == null) {
    this._columns = new System.Collections.Generic.List$1(String)();
    }

    this._columns.add(name);
    },

    C#
    public List<string> _columns = null;
    public void AddColumn(string name)
    {
    if (_columns == null)
    {
    _columns = new List<string>();
    }

    _columns.Add(name);
    }


    BUT WHY????

    Comment


    • #3
      Hi

      Can you post a test case which reproduces the issues? Also did you try latest 15.1 release?

      Comment


      • #4
        You can use http://deck.net/ to reproduce the issue

        Comment


        • #5
          i finish now the update and still the same.

          So here is the code:

          CamlQuery.cs (diferent library)
          namespace SharepointBridgeModels.SP
          {
          public class CamlQuery
          {
          public dynamic _model;
          public int? _totalRows;
          public List<string> _columns;
          public string _query = string.Empty;
          public string _where = string.Empty;
          
          public CamlQuery()
          {
          _model = Script.Call<dynamic>("new SP.CamlQuery");
          }
          
          public dynamic GetQuery()
          {
          if (!string.IsNullOrWhiteSpace(_query))
          {
          return _model;
          }
          else
          {
          
          string auxColumns = string.Empty;
          if (_columns != null && _columns.Count > 0)
          {
          auxColumns = "<ViewFields>";
          foreach (var item in _columns)
          {
          auxColumns += string.Format("<FieldRef Name='{0}'/>", item);
          }
          auxColumns += "</ViewFields>";
          }
          
          string auxRowsCount = string.Empty;
          if(_totalRows.HasValue)
          {
          auxRowsCount = string.Format("<RowLimit>{0}</RowLimit>", _totalRows.Value);
          }
          
          string response = string.Format("<View>{0}{1}{2}</View>", _where, auxColumns, auxRowsCount);
          
          Console.Write("CamlQuery: " + response);
          
          _model.set_viewXml(response);
          
          return _model;
          }
          }
          
          public void SetQuery(string query)
          {
          _query = query;
          }
          
          public void AddColumn(string name)
          {
          if (_columns == null)
          {
          _columns = new List<string>();
          }
          
          _columns.Add(name);
          }
          
          public void AddMaxRows(int totalRows)
          {
          _totalRows = totalRows;
          }
          
          /// <summary>
          /// Incluir o Query /Query
          /// </summary>
          /// <param name="where"></param>
          public void AddWhereAndOrder(string where)
          {
          _where = where;
          }
          
          }
          }
          App.cs
          namespace SharepointBridge
          {
          public class App
          {
          public static ClientContext context;
          
          public static void Main()
          {
          try
          {
          
          Console.WriteLine("Start");
          
          CamlQuery query = new CamlQuery();
          
          query.AddColumn("Dia"); // -> ERROR HERE
          query.AddColumn("Mes");
          query.AddColumn("Colaborador");
          query.AddColumn("Title");
          query.AddColumn("Apelido");
          
          query.AddMaxRows(200);
          
          DateTime hoje = DateTime.Now;
          
          }
          catch (Exception ex)
          {
          Console.Write("Exception: " + ex.ToString());
          }
          }
          
          }
          }

          Comment


          • #6
            Here:
            http://deck.net/af51a72e71ddf9a85ff79c2973ed585f/three

            Comment


            • #7
              The error is diferent because i am using Sharepoint classes. But in my case, have been working and now not

              Comment


              • #8
                Hello,

                I believe your Sharepoint classes library has not been updated to use Bridge 15. If you update that library and recompile, it should solve the error.

                Hope this helps.

                Comment


                • #9
                  No. The issue is not related with SharePoint since it stop works after Chrome update.

                  Comment


                  • #10
                    My Chrome version is 53.0.2785.116 m and I cannot reproduce the issue, your deck sample works fine for me

                    Comment


                    • #11
                      This line raises javascript error because there is no "SP.CamlQuery"
                      _model = Script.Call<dynamic>("new SP.CamlQuery");

                      Comment


                      • #12
                        Found the issue:

                        JS:
                        this._columns = new System.Collections.Generic.List$1(String)();
                        That code looks strange because Bridge generates another code, it wraps `System.Collections.Generic.List$1` by parentheses
                        this._columns = new (System.Collections.Generic.List$1(String))();
                        Code without parentheses can be generated by old version of Bridge, please check what version of compiler do use

                        Comment


                        • #13
                          Correct Vladimir, i modify the .js file to include the ( ) in System.Collections.Generic.List$1 and it works!
                          Know i need to know what i did to build project and compile a .JS version with out ( ) parentheses...

                          Comment


                          • #14
                            btw what is this Bridge Console in Chrome and in FireFox every time i write Console.Write? i don´t want to show that for my clients

                            Comment


                            • #15
                              i don´t want to show that for my clients
                              Don't call Console.WriteLine and the Bridge Console will not render.

                              Comment

                              Working...
                              X