Calling AddOrUpdateValue with a string throws "Value of type String is not supported"
See original GitHub issueCalling AddOrUpdateValue with string type throws exception Value of type String is not supported
.
Here’s how this is possible:
object strValue = "a";
CrossSettings.Current.AddOrUpdateValue(key, strValue);
This is because the implementation is using Type.GetTypeCode
to get the primitive type, but this returns System.TypeCode.Object
, and not System.TypeCode.String
as you could expect.
Same issue is on iOS, it’s very similar code.
As a solution, maybe use Convert.GetTypeCode
which correctly returns TypeCode.String
?
Issue Analytics
- State:
- Created 6 years ago
- Comments:23 (6 by maintainers)
Top Results From Across the Web
Throwing exceptions in application configuration providers
class Configuration string GetValue(string key); // presence ... add only if not present void AddOrUpdateValue(string key, string value); ...
Read more >mysql - How to fix "Incorrect string value" errors?
MySQL's utf-8 types are not actually proper utf-8 – it only uses up to three bytes per character and supports only the Basic...
Read more >Solved: Update Item SP Error - Property selection is not s...
Property selection is not supported on values of type 'String'. ... Is this the reason why I wasn't able to call/select the JSON...
Read more >Posibble to store all data under one excel sheet?
So my test case for POST or PUT just call individual data file. ... int end = 1; //values to new excel file...
Read more >Visual Studio 2013 and .NET 4.5 Expert Cookbook
though the breakpoint exists in the code, it is marked as disabled, and hence the program ... public bool AddOrUpdateValue(string key, object value)....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@opcodewriter I would simply do something like this as the non-generic version:
The already existing private AddOrUpdateValue is unchanged and handles all the cases, including the typecode specific ones. I don’t have any opinion about complex types, as they are not part of the current code.
Yes, i should pass typecode 😃 which i already have, will fix that.