Weird problem passing string array: Cannot deserialize object graph into type of 'System.String[]'

Hi-

I have a strange error occurring, which I can't seem to figure out.  I'm passing an array of strings to a prototyped function, which in turn calls an Atlas function:

SomeTest.prototype.TestArrayPassing= function (myarray) {

    BridgeCanada.WebServices.TestService.TestArray( 
        myarray,
        {
            onMethodComplete: Function.createDelegate(this, this.OnTestArrayComplete),
            onMethodTimeout: Function.createDelegate(this, this.OnTestArrayTimeOut),
            userContext: this
        }
    ); // this doesn't work

var somearray=["Hello There"];
obj.TestArrayPassing(somearray);

... 

 

Here, I'm getting this error:

The server method 'TestArray' failed with the following error:
System.InvalidOperationException: Cannot deserialize object graph into type of 'System.String[]'
However, if I create the array within function, it works fine:
 

SomeTest.prototype.TestArrayPassing2= function () {
   

    var myarray=["Hello There"];
    BridgeCanada.WebServices.TestService.TestArray( 
        myarray,
        {
            onMethodComplete: Function.createDelegate(this, this.OnTestArrayComplete),
            onMethodTimeout: Function.createDelegate(this, this.OnTestArrayTimeOut),
            userContext: this
        }
    );

}  // this works fine

I can work around this currently by creating a new array within the function and copying the passed array into it.  But it's kind of odd.
 
Any ideas on what might be causing this?
 
Thanks!
 
-Mike 
 
0
mikebridge
11/1/2006 4:11:26 PM
asp.net.networking-webservices 2181 articles. 0 followers. Follow

1 Replies
1006 Views

Similar Articles

[PageSpeed] 16

I upgraded to Beta 1, and the error is now this:

 No parameterless constructor defined for type of 'System.String[]'

However, I see that if I put the function definition and the call to that function in the same prototype, it works fine.  It is when one prototyped object calls an object that has a different prototype that the problem occurs.  Strange.

Cheers,

 -Mike

0
mikebridge
11/3/2006 4:32:12 PM
Reply:

Similar Artilces:

Unable to cast object of type 'System.String' to type 'System.Array'
I really need to get this working! I have dimensioned fnames in line 2 to 200 slots. This code gets all the file names in a subdirectory and places them into an array. First files(), a dynamic array, gets the full path. Then line 9 splits it up into it's parts. I grab the last part (the filename) and store it into fnames. The message is  Unable to cast object of type 'System.String' to type 'System.Array'.  How do I get this to work?  Filenames is an array. Line 9 works. It takes a string (str) and converts it into the Array filenames. Why doesn't the n...

"Unable to cast object of type 'System.String' to type 'System.String[]'."
hi i'm using the following statement in my applicationstring[] strTArray = new string[5]; strTArray = (string[])(Session["TextDataArray"]); when i run the application its giving the below error {"Unable to cast object of type 'System.String' to type 'System.String[]'."} can anyone say how to solve this thanks in advance Archu What are you storing in the TextDataArray session? What is the data type you are storing?   RegardsBilal Hadiar, MCP, MCTS, MCPD, MCTMicrosoft MVP - Telerik MVP...

Unable to cast object of type '<>f__AnonymousType1`3[System.Guid,System.String,System.String]' to type 'aspnet_User'.???
Hi everyone, What does this error mean?  ERROR: Unable to cast object of type '<>f__AnonymousType1`3[System.Guid,System.String,System.String]' to type 'aspnet_User'. Thank's a lot /PepePepe JoseNewbie@C#.Net&jRuby What type is in your DataItem?  A Guid? or a String?  Either way, it's telling you cant cast it to a aspnet_User type.  Let us know what your DataItem is and we can help further.Good Luck and happy programming!Let's build community! If my post helped you, mark it as the Answer and I will do the same when you help me.....

Unable to cast object of type 'System.String' to type 'System.String[]
 Hey Guys,Am trying to create a system for managing User roles on my site. To do this the user is selected from a gridview (gvMembers) and their info appears in another panel.  The DataKeyNames for this gridview is "UserName". I then have a check box for each role so 1 or multiple roles can be selected. The code behind for updating the roles from one of the checkboxes is shown below:  If ChkAdmin.Checked Then If Roles.IsUserInRole(gvMembers.SelectedValue, ChkAdmin.Text) = False Then Roles.AddUsersToRole(gvMembers.SelectedValue, ChkAdm...

System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Byte[]'.
Hi All, I am trying to retrieve a Picture from an SQL 2005 database. Here is my code:Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim ListingID As String = (Request.QueryString("GUID")) 'Connect to the database and bring back the image contents & MIME type for the specified pictureUsing myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionStringListings").ConnectionString) Const SQL As String = "SELECT [Pic1Ext], [Picture1] FROM [Listings] WHERE [ListingID] = @ListingID"C...

System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.String'
Hello , I am a data table with null able Columns.I am not able to catch the value for DBNull. I did set a value to be returned as empty in dataset. Here is the code where i am trying to catch.1 public List GetStores() 2 { 3 List tmpStore = new List(); 4 StoresService.shopDBDataSet.StoresDataTable stores = 5 storesService.GetStores(); 6 for (int i = 0; i < stores.Count ; i++) 7 { 8 Store store = new Store(); 9 store.StoreID = stores[i].StoreID...

Unable to cast object of type 'System.UInt32' to type 'System.String'?
Hi all,I'm trying to retrieve a column in my table (MySQL), this is the primary key of that table, and here is my code: public string GetAsocPKByUserName(string UserName) { MySqlConnection conn = new MySqlConnection(); MySqlCommand myCommand = new MySqlCommand(); string ASOC_PK = string.Empty; try { conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); conn.Open(); myCommand = new MySqlCommand("SELECT Distinct ASOC_PK FROM asso...

Unable to cast object of type 'System.DBNull' to type 'System.String'.
Hi i have the following which is meant to check if an image is available and if it isnt it should show a default image however, it gives me this error whenever the image is null in the database. This is the function which returns the error;protected string FormatImageUrl(object url) {if ((url != DBNull.Value) && (url != null) && (url.ToString().Trim().Length > 0)) { //if (File.Exists(url))return (url.ToString().Trim()); } else {return "~/images/default.gif"; } } Hey,Doesn't seem to pass the dbnull check.  Try to do:  if ((!DBNull.Valu...

Unable to cast object of type 'System.DBNull' to type 'System.String'.
Hi All, I am using Sql server 2005 and VS 2005 C#. Can anybody explain howz solve this prob? Unable to cast object of type 'System.DBNull' to type 'System.String'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.String'.Source Error: Line 3496: get { Line 3497: try { Line 3498: ...

Unable to cast object of type 'System.DateTime' to type 'System.String'.
 Hi,      I got this field (dateSubmitted) having a data type of DateTime but I receive this error "Unable to cast object of type 'System.DateTime' to type 'System.String'."       All value for dateSubmitted field are 12/27/2007 12:00:00 AM. cheers,imperialx  imperialx:I got this field (dateSubmitted) having a data type of DateTime but I receive this error "Unable to cast object of type 'System.DateTime' to type 'System.String'." Can you explain it further as to, ...

Unable to cast object of type 'System.DBNull' to type 'System.String'
I have received the following error when I am logged in as administrator.  I wanted to test the load event feature.  Allows me to load and save new event.  I can view event on location view page but when I try to link to "list or calender" view I receive this error "Unable to cast object of type 'System.DBNull' to type 'System.String'.  Debug highlights the <asp:HyperlinkID as errored line. Any assistance would be greatly appreciated Brian   <DayEventTemplate> <div style="padding: 3px;"> <asp:Hyper...

Unable to cast object of type 'System.String[]' to type 'System.IConvertible'.
hi expert   i try get the string from request.querystring("CID") from the error messege i know that is string[] (array) how to convert it to int32 and request.querystring("CID") is int value   Line 19: protected void ObjectDataSourceCarPicture_Inserting(object sender, ObjectDataSourceMethodEventArgs e) Line 20: { Line 21: e.InputParameters.Add("CID", Convert.ToInt32(Request.QueryString.GetValues("CID")) ); Line 22: // e.InputParameters.Add("CID", Convert.ToInt32( Convert.ToString( a Request.QueryString.GetValues("CID"))))); Line 23: ...

Object of type 'System.DBNull' cannot be converted to type 'System.String' from formview
I have a formview that I am using for input to my datatable.  I am using an objectdatasource that uses a BLL.  This in turn points to my XSD tableadapter. When I test, and only fill in the required fields, I am getting the error Object of type 'System.DBNull' cannot be converted to type 'System.String' I am not sure what field is having the issue.  In my BLL for the Add, I have checked the dates for null and placed the value of DateTime.MinValue.  For the text fields, I have place "" if they are null.  Is this error being create prior to...

Unable to cast object of type 'System.DBNull' to type 'System.String'.
Hi i get the following error, Unable to cast object of type 'System.DBNull' to type 'System.String'.  A generic image is meant to appear when no image is found in the database for a particular product, this is how the code is laid out;protected string FormatImageUrl(string url) {if (url != null && url.Length > 0) { //if (File.Exists(url))return (url); } else {return "~/Images/CompanyProducts/No_image.jpg"; } }   And the html is like this; <asp:Image ID="Image1" ImageUrl='<%# (string) FormatImageUrl( (string) Ev...

Web resources about - Weird problem passing string array: Cannot deserialize object graph into type of 'System.String[]' - asp.net.networking-webservices

Resources last updated: 1/19/2016 1:16:29 PM