Web Service returning a datatable with Atlas Beta 1

Last post 11-10-2006 1:55 AM by jhlmr2. 6 replies.

Sort Posts:

  • Web Service returning a datatable with Atlas Beta 1

    10-26-2006, 11:27 AM
    • Participant
      1,984 point Participant
    • Wallym
    • Member since 06-02-2003, 1:10 PM
    • Tennessee
    • Posts 361
    • ASPInsiders
      TrustedFriends-MVPs
    I'm having a problem trying to get a dataset/datatable from a web service with Atlas Beta 1 that was just released.  The problem seems to occur before the data is sent through the web service and occurs on the server.  The specific error is below.  It is very similar to an error that I got with the first public bits in Sept. 2005.  I am manually creating the datatable and sending it out on the web service.  The datatable itself is fairly simple.  This code worked with the July CTP.  If you have any suggestions, let me know.
     
    Message: A circular reference was detected while serializing an object of type 'System.Reflection.Module'.
    Stack Trace: at Microsoft.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth) at Microsoft.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth) at Microsoft.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(Object o, StringBuilder sb, Int32 depth) at Microsoft.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth) at Microsoft.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth) at Microsoft.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(Object o, StringBuilder sb, Int32 depth) at Microsoft.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth) at Microsoft.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth) at Microsoft.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(Object o, StringBuilder sb, Int32 depth) at Microsoft.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth) at Microsoft.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth) at Microsoft.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(Object o, StringBuilder sb, Int32 depth) at Microsoft.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth) at Microsoft.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth) at Microsoft.Web.Script.Serialization.JavaScriptSerializer.SerializeEnumerable(IEnumerable enumerable, StringBuilder sb, Int32 depth) at Microsoft.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth) at Microsoft.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth) at Microsoft.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(Object o, StringBuilder sb, Int32 depth) at Microsoft.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth) at Microsoft.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth) at Microsoft.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj) at Microsoft.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams) at Microsoft.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)
    Exception Type: System.InvalidOperationException
    Filed under: ,
  • Re: Web Service returning a datatable with Atlas Beta 1

    10-26-2006, 2:55 PM
    • Member
      30 point Member
    • wleary
    • Member since 09-11-2006, 4:09 PM
    • Posts 6
    I'm having same issue. Supposedly the changes doc suggests the CTP Beta supports the Data classes, but I see no direction on how to do that.
  • Re: Web Service returning a datatable with Atlas Beta 1

    10-26-2006, 3:05 PM
    • Member
      30 point Member
    • wleary
    • Member since 09-11-2006, 4:09 PM
    • Posts 6

    Made slight progress. Reflected the code and found the DataTableConverter in the Preview assembly that comes with the CTP Beta. Added the following to my web.config:

    <jsonSerialization maxJsonLength="5000000">

    <converters>

    <add name="DataTableConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataTableConverter"/>

    </converters>

    </jsonSerialization>

    But, the DataTable that gets returned is missing methods it used to have, such as get_length().

    Argh. This just sucks. 

     

     

  • Re: Web Service returning a datatable with Atlas Beta 1

    10-26-2006, 4:04 PM
    • Member
      30 point Member
    • wleary
    • Member since 09-11-2006, 4:09 PM
    • Posts 6

    OK. I think after digging around I've got it. At least it appears as such.

     First thing, after adding a reference to the Preview CTP Beta assembly, and adding the converter for the data table to your web.config, then make sure you add the PreviewScript.js to your project, and add a reference to it in your pages ScriptReference tag, in the ScriptManager. Then, once you have that, then you can instantiate a new DataTable, like so:

     <snip>

    onGetAllTabsComplete: function(tbl) {
                    if (tbl != null) {
                        eval('var tblrows = ' + tbl.dataArray.slice(0, tbl.dataArray.length-1) + ';');            <-- NOTE THIS LINE. I THINK THERE'S A BUG, SINCE THE dataArray has a trailing ')'.        
                        tbl = new Sys.Preview.Data.DataTable(tbl.columns, tblrows);
                        for (var i = 0; i < tbl.get_length(); i++) {
                            var row = tbl.getItem(i);               
                            _editor.createTabNode(row.getProperty("ID"), row.getProperty("Title"), row.getProperty("MenuItemID"));
                        }
                    }   

    </snip>

    Atlas team, what in the hell is up?! This is, frankly, one of the most bass-ackwards releases I've ever seen from you guys. How, after so many friggin CTP's, do you just bust out and drop this crap on us.

    Pissed in San Antonio,

    William

     

  • Re: Web Service returning a datatable with Atlas Beta 1

    10-27-2006, 10:13 AM
    • Participant
      1,984 point Participant
    • Wallym
    • Member since 06-02-2003, 1:10 PM
    • Tennessee
    • Posts 361
    • ASPInsiders
      TrustedFriends-MVPs
    Thanks William. This is good info.

    Wally

    wrote in message news:1443001@forums.asp.net...
    > OK. I think after digging around I've got it. At least it appears as such.
    >
    > First thing, after adding a reference to the Preview CTP Beta assembly,
    > and adding the converter for the data table to your web.config, then make
    > sure you add the PreviewScript.js to your project, and add a reference to
    > it in your pages ScriptReference tag, in the ScriptManager. Then, once you
    > have that, then you can instantiate a new DataTable, like so:
    >
    >
    >
    > onGetAllTabsComplete: function(tbl) {
    > if (tbl != null) {
    > eval('var tblrows = ' + tbl.dataArray.slice(0,
    > tbl.dataArray.length-1) + ';');
    > THERE'S A BUG, SINCE THE dataArray has a trailing ')'.
    > tbl = new Sys.Preview.Data.DataTable(tbl.columns,
    > tblrows);
    > for (var i = 0; i
    > var row = tbl.getItem(i);
    > _editor.createTabNode(row.getProperty("ID"),
    > row.getProperty("Title"), row.getProperty("MenuItemID"));
    > }
    > }
    >
    >
    >
    >
    > Atlas team, what in the hell is up?! This is, frankly, one of the most
    > bass-ackwards releases I've ever seen from you guys. How, after so many
    > friggin CTP's, do you just bust out and drop this crap on us.
    >
    > Pissed in San Antonio,
    >
    > William
    >
    Listen to the ASP.NET Podcast @ http://www.aspnetpodcast.com/
  • Re: Web Service returning a datatable with Atlas Beta 1

    11-09-2006, 4:01 AM
    • Member
      10 point Member
    • jhlmr2
    • Member since 11-09-2006, 3:20 AM
    • Posts 2

     I use Preview CTP Norvember Beta assembly, and make client source as follow.

     tbl = new Sys.Preview.Data.DataTable(tbl.columns, tblrows);

    No matter how tbl.columns and tblrows is not null, I get the result zero of  tbl.get_length();

    Why?

     

  • Re: Web Service returning a datatable with Atlas Beta 1

    11-10-2006, 1:55 AM
    • Member
      10 point Member
    • jhlmr2
    • Member since 11-09-2006, 3:20 AM
    • Posts 2

    Maybe bug of Sys.Preview.Data.DataTable creator.

    In Microsoft.Web.Resources.ScriptLibrary.PreviewScript.js, when the Sys.Preview.Data.DataTable instance create,

    to compare Array type and arguments tbl.columns and  tblrows is mistake.

    Hence, I'll modify the client source as follow.

     

    function Button1_onclick() {
        var results = GauceWebService.Select(OnSuccess);
        return false;
    }

    function OnSuccess(result)
    {
         var tblrows = new Array();
         var tblcols = new Array();
         var strRowsData = "";
         var strColssData = "";
           
         if (result != null)
         {
         //debugger;
            result.dataArray = result.dataArray.slice(0, result.dataArray.length-1);   
       
            strRowsData = result.dataArray.substring(1);
            strRowsData = strRowsData.substring(0, strRowsData.length-1);
           
            tblrows = strRowsData.split("},{");
            for(var j=0; j< tblrows.length; j++)
            {
                if(j==0)
                {
                    tblrows[j] = tblrows[j].toString().substring(1);
                }
                else if(j==tblrows.length-1)
                {
                    tblrows[j] = tblrows[j].toString().substring(0, tblrows[j].toString().length-1);
                }           
            }
           
            strColssData = result.columns.substring(1);
            strColssData = strColssData.substring(0, strColssData.length-1);
            //alert("strColssData = " + strColssData);
            tblcols = strColssData.split("),");
          
            for(var j=0; j< tblcols.length; j++)
            {
                if(j< tblcols.length-1)
                {
                    tblcols[j] = tblcols[j].toString() + ")";
                }
            }
        
            //result = new Sys.Preview.Data.DataTable(result.columns, tblrows);  // Maybe result.columns and tblrows type are string...
            result = new Sys.Preview.Data.DataTable(tblcols, tblrows);
            //alert("result.get_length() = " + result.get_length());
            for (var i = 0; i < result.get_length(); i++) {
                var row = result.getItem(i);  
                alert("Row[" + (i+1) + "] \r\n" + "Name=" + getProperty(row, "Name") + "\r\n" + "LastName=" + getProperty(row, "LastName") + "\r\n" + "Email=" + getProperty(row, "Email"));
                //alert("Name=" + row.getProperty("Name") + "," + "LastName=" + row.getProperty("LastName") + "," + "Email=" + row.getProperty("Email"));
           }
        }

    }

    function getProperty(rowObj, name)
    {
        var rowstring = rowObj._row;
        var strColValue = "";
        var strKeyName = "\"" + name + "\":";
        var nLastIndex = rowstring.lastIndexOf(strKeyName);
       
        if(nLastIndex == -1)
        {
            return "";
        }
        else
        {
            var strTmpValue = rowstring.substring(nLastIndex + strKeyName.length-1);
          
            if(strTmpValue.indexOf(",") == -1)
                strColValue = strTmpValue.substring(2, strTmpValue.length-1);
            else
                strColValue = strTmpValue.substring(2, strTmpValue.indexOf(",")-1);
        }
       
        return strColValue;

     

Page 1 of 1 (7 items)