w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Nhibernate throws Object of type 'System.Linq.EnumerableQuery`1[Entity]' cannot be converted to type 'System.Linq.IQueryable`1[System.Object[]]'
.AsQueryable() will wrap the given IQueryable from NH needlessly into a new Queryable but since NH will by default use object arrays as results and transform it later it will fail casting. Also Selecting the user into another User will prevent changetracking and is needless copying. repo.GetAll().Where(f => f.Id == id).FirstOrDefault(); should be enough or even better because of the sessioncache usage var user = session.Get<User>(id); if (user == null) // user with given Id does not exist

Categories : C#

How to change the Assemby and the Object type on the Newtonsoft.Json serialization/deserialization? Am using .NET MVC 3 and WPF
I stand by my original answer - type information in serialization data is just really messy - it would be far better to change the code not to need this, but to "fix" it (not sure that is the right word) - look carefully at the typeName - it isn't always what you are expecting: public class MySerializationBinder : DefaultSerializationBinder { public override Type BindToType(string assemblyName, string typeName) { switch(typeName) { case "WebSolution.MyModel[]": return typeof(Application.MyModel[]); case "WebSolution.MyModel": return typeof(Application.MyModel); default: return base.BindToType(assemblyName, typeName); } } } Incidentally, once the array type is known, the element type is implicit - so you can save so

Categories : C#

Object of type 'System.Reflection.MdFieldInfo' cannot be converted to type 'MyEnum'
I think you need a Field.GetValue here type.GetProperty("St").SetValue(student, type3.GetField("Good").GetValue(instance), null); Type.GetField returns FieldInfo but what you actually need to pass as a parameter is enum value. Note: I assume Good is a field on type3 which is of type Enum StudentType

Categories : C#

How to fix Sys.ArgumentTypeException: Object of type 'Object' cannot be converted to type 'Function'
The remove_endRequest accepts function that you want to remove from the list of handlers for endRequest Event. So the code you provided has invalid parameter because call of $(document).ready() returns the jQuery "wrapper" object instead of handler function. If you want to call code after the end of async postback you should use add_endRequest and remove $(document).ready since it is not tied to the async postback events. <script type="text/javascript"> function Navigate() { $('#dialogDiv').dialog('open'); } function myEndRequestHandler() { var list = ""; $('#dialogDiv').dialog({ autoOpen: false, resizable: true, width: 300, height: 'auto', buttons: { "Save": function (

Categories : C#

org.json.JSONException: Value [] of type org.json.JSONArray cannot be converted to JSONObject
you get from the server a (maybe empty) json array and you are try to convert it in a JsonObject. instead of JSONObject obj = new JSONObject(string); you should do JSONArray obj = new JSONArray(string);

Categories : Android

Value of type org.json.JSONObject cannot be converted to JSONArray
Try This Code: String json = yourCartConnect.getYourCartDetails(); try { JSONObject jsonObject = new JSONObject(json) JSONArray jResult = jsonObject.getJSONArray("Your array key"); for(int i=0;i<jResult.length();i++){ JSONObject f = jResult.getJSONObject(i); // write your remaining code here } setList(yourCartEntries); } catch (JSONException e) { Log.e("YourCartActivity", "Error parsing data " + e.toString()); errorConnectToServer(); }

Categories : Android

"Object of type 'System.object[]' cannot be converted to type 'system.string'"
Using your code, I wrote an example. This is error free and I hope it helps you! static void Main(string[] args) { Dictionary<string, Object> dic = new Dictionary<string, Object>(); dic.Add("tester1", new object()); dic.Add("tester2", new object()); dic.Add("tester3", new object()); dic.Add("tester4", new object()); dic.Add("tester5", new object()); dic.Add("tester6", new object()); Console.WriteLine("Starting loop..."); foreach (KeyValuePair<string, Object> kvp in dic) { var x = kvp.Key; var y = kvp.Value; Console.WriteLine(String.Format("Key: {1}, Value: {2}{0}", Environment.NewLine, x, y)); } Console.WriteLine("Finished Loop

Categories : C#

JSON Schema: represent constraint to encode object type in string type
I agree, either you choose the object or string type. I have looked into the JSON Schema documentation and I could not find anything to express the constraint as clear as needed. Hence, a short discussions of the two approaches there are to my mind. Type String JSON Schema defines seven primitive types, including object. A string is simply defined as a JSON string. The RFC 4627 defines a JSON string as follows A string is a sequence of zero or more Unicode characters This would apply to your case, even though the content of the string has to be restricted. The question is how to communicate the restriction. I would use a description to reference to another subschema. You can even define a pattern for the string an encode the subschema as regular expression. This, however,

Categories : Javascript

Could not determine JSON object type for type System.Char
If you are getting multiple randoms in sequence may need to change your code to generate better randoms but this will work for creating a JArray var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; var random = new Random ( ); var result = JArray.FromObject ( Enumerable.Repeat ( chars , 1 ) .Select ( s => s [ random.Next ( s.Length ) ] ) .ToArray ( ) );

Categories : C#

Unable to cast object of type 'System.Linq.OrderedEnumerable`2[***]' to type 'System.Collections.Generic.IEnumerable`1[***]'
You're trying to convert a collection of DirectoryToken to a collection of Token. This is called a covariant conversion, and it's only supported in .Net 4.0 or later. If you can't upgrade, you can call .Cast<Token>() to create a new IEnumerable<T> instance (actually an iterator) that casts each object to the desired type. Under no circumstances do you need an explicit cast operation.

Categories : C#

org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
while ((line = reader.readLine()) != null){ sb.append(line + " "); } instead try while ((line = reader.readLine()) != null){ sb.append(line); json = sb.toString().substring(0, sb.toString().length()-1); } Follow this method for getting json object: public JSONObject getJSONObjFromUrl(String url, List<NameValuePair> params) { System.out.println("url:: "+url ); System.out.println("params:: "+ params +" " +params.get(0) ); // Making HTTP request try { // defaultHttpClient DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url); httpPost.setEntity(new UrlEncodedFormEntity(params)); HttpResponse httpR

Categories : Android

org.json.JSONException: Value < of type java.lang.String cannot be converted to JSONObject
The JSON string you're trying to parse may be invalid it's got some raw HTML(< like), which mean it's either badly generated, or PHP is inserting errors/warnings and destroying the string

Categories : Android

org.json.jsonexception value of type java.lang.string cannot be converted to jsonarray
In your php code, you print each name once in the while loop : echo $players[$i]; Then you print it again when you print the json array : print(json_encode($players)); So in the result, you have the following : Santi Carzola Alex Chamberlin Theo Walcott ["Santi Carzola","Alex Chamberlin","Theo Walcott"] Which is not an JSONArray. You need to get rid of what is before the [, so remove the echo $players[$i]; from your loop and it should work.

Categories : Android

The given value of type String from the data source cannot be converted to type bigint of the specified target column
I found an answer in this bytes.com thread. All you have to do is map the columns of the source to the destination table with the use of SqlBulkCopyColumnMapping. bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping(0, 1)); bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping(1, 2)); bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping(2, 3)); bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping(3, 6)); //look here, index is different bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping(4, 8)); //and again bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping(5, 9)); I also found the same solution here before finding the above, but in my case I had some fields missing in the source. The fields were in the correct order although it referred to the actual INDEX/ORD

Categories : C#

SqlBulkCopy - The given value of type String from the data source cannot be converted to type money of the specified target column
@Corey - It just simply strips out all invalid characters. However, your comment made me think of the answer. The problem was that many of the fields in my database are nullable. When using SqlBulkCopy, an empty string is not inserted as a null value. So in the case of my fields that are not varchar (bit, int, decimal, datetime, etc) it was trying to insert an empty string, which obviously is not valid for that data type. The solution was to modify my loop where I validate the values to this (repeated for each datatype that is not string) //--- convert decimal values foreach (DataColumn DecCol in DecimalColumns) { if(string.IsNullOrEmpty(dr[DecCol].ToString())) dr[DecCol] = null; //--- this had to be set to null, not empty else dr[DecCol] = Helpers.CleanDec

Categories : C#

SQL Bulk Copy "The given value of type String from the data source cannot be converted to type datetime of the specified target column" using ASP.NET
SqlBulkCopy.WriteToServer(DataTable) fails with confusing messages if the column order of the DataTable differs from the column order of the table definition in your database (when this causes a type or length incompatibility). Apparently the WriteToServer method does not map column names.

Categories : C#

How to fine control how a SOAP response type is converted into a PHP type?
You can transform that result in almost anything in PHP via that classmap feature, but the question is if you should, because the same Soap data structures are usually used for both requests and responses. Reuse them! My general approach is to use the classmap feature to map all those ComplexType structures onto PHP classes. And if that structure does not fit well to the intended use, I have a mapper step that transforms the result in PHP.

Categories : PHP

get JSONException: Value of type java.lang.String cannot be converted to JSONObject when parsing a JSON response
You web service is not creating valid JSON. A JSON string can only start with { or [. Yours starts with the String "Array". You can read about the JSON format in its Wikipedia entry here.

Categories : Java

Error Parsing Data org.json.JSONException: Value of type java.lang.String cannot be converted to JSONArray
Try using: JSONObject jObj = jArray.getJSONObject(i); Instead of: jArray.getString(i); // JSONObject // json = jArray.getJSONObject(i); JSONObject jObj = new JSONObject(json);

Categories : Java

android error org.json.JSONException: Value
i find the solution it's about apache server configuration <Directory "/home/domain/www"> Options +Indexes FollowSymLinks +ExecCGI AllowOverride AuthConfig FileInfo Order allow,deny Allow from all **here you need to change deny from all to Allow from all** </Directory>

Categories : Java

Error parsing data org.json.JSONException: type java.lang.String cannot be converted to JSONObject
If you are getting error only after introducing the PHP line then you may have error in the query itself. Try dumping the query to get more insights. SELECT * FROM profiles_profilelistitems WHERE ProfileListID = ".$row["ProfileListName"] should be SELECT * FROM profiles_profilelistitems WHERE ProfileListID = '".$row["ProfileListName"]."'"

Categories : Java

MvxBind Error: "Null object can not be converted to a value type" thrown before the first screen is displayed
The idea of this occurring before the android app displays the initial "SplashScreen.axml" view. is slightly alarming - as the splashscreen is generally displayed before most of MvvmCross, including the binding system, is bootstrapped. Reading through the description, I've no idea what the issue is. Really not sure how you are getting binding errors before the splash screen is shown. It's probably related to the MakeSafeValue type conversion - but I "believe" that this can correctly handle conversion from Null for enum values - see the test case on MakeSafeValueTest.cs#L98 To debug this, I'd recommend: Ensure you are working with the very latest MvvmCross releases (3.0.9 on nuget, July 13th on Mvvmcross-Binaries, or tagged 3.0.9 on MvvmCross repo) Try creating a new simple pr

Categories : Android

Error parsing data org.json.JSONException: Value