Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'TypeConverter cannot convert from System.String.' after upgrade to VS2019 #3726

Closed
rusanov-vladimir opened this issue Oct 2, 2019 · 4 comments · Fixed by #3770
Closed
Assignees
Labels
Area: Mono Runtime Mono-related issues: BCL bugs, AOT issues, etc. bug Component does not function as intended. vs-sync For internal use only; creates a VSTS "mirror" issue.

Comments

@rusanov-vladimir
Copy link

rusanov-vladimir commented Oct 2, 2019

Steps to Reproduce

Following code doesn't work after upgrading to VS2019.

        var typeConverter = TypeDescriptor.GetConverter(typeof(Color));
        var clr = (Color)typeConverter.ConvertFromString("#FFAAEE"); -// --->Exception
        var toSerialize = new TestClass { Color = clr };
        var str = JsonConvert.SerializeObject(toSerialize);
        var deserialized = JsonConvert.DeserializeObject<TestClass>(str); //--->deserialized.Color is empty
  1. Use VisualStudio 2019 > 16.2
  2. Clone https://github.com/rusanov-vladimir/color-issue
  3. Set PG17.Droid as start project and run it. Click on the Letter envelope FAB.

Expected Behavior

See a toast saying "Everything works fine! Gratz!" both in VS 2019 and VS 2017 when using code above.

Actual Behavior

Behavior using VS 2019 16.3.1:
First issue that happens: System.NotSupportedException: 'TypeConverter cannot convert from System.String.' If conversion from string to System.Drawing.Color is performed in a different manner or replaced with some standard color next, probably related, issue that happen is: serialization and deserialization of object that contains System.Drawing.Color doesn't work. Color after deserialization isn't the same as it was before. It's likely related to the fact that Json.Convert uses TypeDescriptor to get color converter.

Behavior using VS 2017 15.9.15:
Everything works and toast message is displayed.

ConsoleApplication targeting .net core 2.1 also works fine.

Version Information

Microsoft Visual Studio Professional 2019
Version 16.3.1
VisualStudio.16.Release/16.3.1+29324.140
Microsoft .NET Framework
Version 4.7.03062

Installed Version: Professional

Application Insights Tools for Visual Studio Package 9.1.00913.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2019 16.3.283.64955
ASP.NET and Web Tools 2019

ASP.NET Web Frameworks and Tools 2019 16.3.283.64955
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 16.3.283.64955
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools 16.3.283.64955
Azure Functions and Web Jobs Tools

C# Tools 3.3.1-beta3-19461-02+2fd12c210e22f7d6245805c60340f6a34af6875b
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Extensibility Message Bus 1.2.0 (d16-2@8b56e20)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

IntelliCode Extension 1.0
IntelliCode Visual Studio Extension Detailed Info

Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 0x10 - v2.9.20816.1

Microsoft Continuous Delivery Tools for Visual Studio 0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager 2.0.83+gbc8a4b23ec
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Mono Debugging for Visual Studio 16.3.7 (9d260c5)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 5.3.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Open Command Line 2.4.226
2.4.226

ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

SQL Server Data Tools 16.0.61908.27190
Microsoft SQL Server Data Tools

TypeScript Tools 16.0.10821.2002
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 3.3.1-beta3-19461-02+2fd12c210e22f7d6245805c60340f6a34af6875b
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.4 for F# 4.6 16.3.0-beta.19455.1+0422ff293bb2cc722fe5021b85ef50378a9af823
Microsoft Visual F# Tools 10.4 for F# 4.6

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Containers 1.0
Visual Studio Tools for Containers

VisualStudio.Mac 1.0
Mac Extension for Visual Studio

Xamarin 16.3.0.274 (d16-3@06531f8)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 16.3.0.230 (remotes/origin/d16-3-xcode11@bbe518670)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 16.3.565 (27e9746)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 10.0.0.43 (d16-3/8af1ca8)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: mono/mono@7af64d1ebe9
Java.Interop: xamarin/java.interop/d16-3@5836f58
LibZipSharp: grendello/LibZipSharp/d16-3@71f4a94
LibZip: nih-at/libzip@b95cf3f
ProGuard: xamarin/proguard@905836d
SQLite: xamarin/sqlite@8212a2d
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-3@cb41333

Xamarin.iOS and Xamarin.Mac SDK 13.2.0.42 (5e8a208)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

VS bug #1000655

@grendello
Copy link
Contributor

Exception thrown on XA/master:

10-04 09:50:14.260  7307  7307 I MonoDroid: System.NotSupportedException: TypeConverter cannot convert from System.String.
10-04 09:50:14.260  7307  7307 I MonoDroid:   at System.ComponentModel.TypeConverter.GetConvertFromException (System.Object value) [0x0003e] in <2e0bad94519047a8a9d01a6148afded6>:0 
10-04 09:50:14.260  7307  7307 I MonoDroid:   at System.ComponentModel.TypeConverter.ConvertFrom (System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, System.Object value) [0x00011] in <2e0bad94519047a8a9d01a6148afded6>:0 
10-04 09:50:14.260  7307  7307 I MonoDroid:   at System.ComponentModel.TypeConverter.ConvertFromString (System.String text) [0x00000] in <2e0bad94519047a8a9d01a6148afded6>:0 
10-04 09:50:14.260  7307  7307 I MonoDroid:   at PG.Droid.MainActivity.FabOnClick (System.Object sender, System.EventArgs eventArgs) [0x00011] in <2cf25d5251f54f658feaa7b18482bb20>:0 
10-04 09:50:14.260  7307  7307 I MonoDroid:   at Android.Views.View+IOnClickListenerImplementor.OnClick (Android.Views.View v) [0x00017] in <53380b04f2d9440b87ae2f5bf9f8823c>:0 
10-04 09:50:14.260  7307  7307 I MonoDroid:   at Android.Views.View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v) [0x00012] in <53380b04f2d9440b87ae2f5bf9f8823c>:0 
10-04 09:50:14.260  7307  7307 I MonoDroid:   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.16(intptr,intptr,intptr)

@grendello grendello added Area: Mono Runtime Mono-related issues: BCL bugs, AOT issues, etc. bug Component does not function as intended. regression labels Oct 4, 2019
@grendello grendello added this to the Under Consideration milestone Oct 4, 2019
@marek-safar
Copy link
Contributor

@akoeplinger could you please look into this. I suspect this is due to the refactoring we have done for System.Drawing and we forgot to include [TypeTypeConverter] attributes for mobile

/cc @steveisok

akoeplinger added a commit to akoeplinger/mono that referenced this issue Oct 8, 2019
monojenkins pushed a commit to monojenkins/mono that referenced this issue Oct 8, 2019
akoeplinger added a commit to akoeplinger/mono that referenced this issue Oct 8, 2019
akoeplinger added a commit to akoeplinger/mono that referenced this issue Oct 8, 2019
akoeplinger pushed a commit to mono/mono that referenced this issue Oct 9, 2019
* Add drawing type converters to mobile profiles

Needed for dotnet/android#3726

* Bump API snapshot submodule

* [csproj] Update project files
akoeplinger added a commit to mono/mono that referenced this issue Oct 9, 2019
* [2019-06] Add drawing type converters to mobile profiles

Needed for dotnet/android#3726

* Bump API snapshot submodule

* [csproj] Update project files
akoeplinger added a commit to mono/mono that referenced this issue Oct 9, 2019
* [2019-08] Add drawing type converters to mobile profiles

Needed for dotnet/android#3726

* Bump API snapshot submodule

* [csproj] Update project files
akoeplinger added a commit to mono/mono that referenced this issue Oct 9, 2019
* Add drawing type converters to mobile profiles

Needed for dotnet/android#3726

* Bump API snapshot submodule

* [csproj] Update project files
grendello added a commit to grendello/xamarin-android that referenced this issue Oct 11, 2019
Fixes: dotnet#3726
Context: mono/mono@0f241c9

Other changes in the range:

 * mono/mono@df5e13f95df [tests] Bump corefx to get Azure testhost change (#17275)
 * mono/mono@11e1499c227 [2019-08] [merp] Print missing status marker file for stage 1 (setup) (#17220)
 * mono/mono@7dbad3c3618 [arm] Fix fetching of method addresses (#17253)
 * mono/mono@9a88a36789e [sgen] Fix invalid value passed to write barrier (#17247)
 * mono/mono@0f241c975ce [2019-08] Add drawing type converters to mobile profiles (#17240)
 * mono/mono@7ebe1a1763c Update Roslyn to 3.4.0-beta2-19477-01
 * mono/mono@b759449ba8d Bump msbuild to track mono-2019-08
 * mono/mono@617f399efca [IO] Remove read-only logic in mono_w32_get_disk_free_space (#17211)
 * mono/mono@77258ea1122 [2019-08] [debugger][exception] Debugger breaks on handled exceptions (#17202)
 * mono/mono@f83c321f88f Bump msbuild to track mono-2019-08 (#17193)
 * mono/mono@1ecd094b44c [2019-08] [Mono.Debugger.Soft] Fix VirtualMachine detaching (#17077)
 * mono/mono@54a33be9dee [merp] Put thread into async context before running summarizer (#17197)
 * mono/mono@72128bb00d3 Bump libgdiplus to 6.0.4
 * mono/mono@65a972c0333 Always do copy_stack_data on entering GC safe/unsafe mode. (#17184)
 * mono/mono@9e6def1553b [merp] exit_status is 0 if we ran the uploader successfully (#17187)
 * mono/mono@8a707cc0124 [2019-08] [reflection] Only duplicate MonoMarshalSpec strings for custom types (#17189)
 * mono/mono@bd72952cf82 [2019-08] [merp] Don't overrun buffer in copy_summary_string_safe … (#17178)
 * mono/mono@b6efc0cc906 Bump msbuild to track xplat-master (#17132)
 * mono/mono@2869cd5f67e Bump ikvm to get mono/ikvm-fork#13 (#17170)
 * mono/mono@a64a25695d6 [2019-08] [merp] Use macOS version not Darwin version in MERP reports (#17147)
 * mono/mono@57f068438d4 [2019-08] [merp] Add API method that whitelists all native libraries (#17128)
@grendello grendello mentioned this issue Oct 11, 2019
@jonpryor jonpryor modified the milestones: Under Consideration, d16-3 Oct 11, 2019
@jonpryor jonpryor added the vs-sync For internal use only; creates a VSTS "mirror" issue. label Oct 11, 2019
jonpryor added a commit that referenced this issue Oct 11, 2019
jonpryor added a commit to jonpryor/xamarin-android that referenced this issue Oct 16, 2019
jonpryor added a commit that referenced this issue Oct 16, 2019
jonpryor added a commit to jonpryor/xamarin-android that referenced this issue Oct 16, 2019
Changes: mono/mono@5281037...3eb5f34

Fixes: dotnet#3726

Context: mono/mono@0f241c9
Context: mono/mono#7377
Context: mono/mono#16570
Context: mono/mono#17004
Context: mono/mono#17151
Context: mono/mono#17180

  * mono/mono@3eb5f34f541: [GTK] Bump bockbuild for GtkViewport autoscrolling patch. (#17321)
  * mono/mono@b601371d5f0: Update MERP event type to MonoAppCrash
  * mono/mono@6184ff007b2: [2019-08][ci] Use Xcode11.1 and 11.2beta2 for XI/XM Mono SDK builds (#17324)
  * mono/mono@8969f2cc99b: [2019-08] [merp] Include any managed methods in the 'unmanaged_frames' portion (#17316)
  * mono/mono@30094401081: [2019-08][merp] Don't install SIGTERM handler in EnableMicrosoftTelemetry (#17308)
  * mono/mono@df5e13f95df: [tests] Bump corefx to get Azure testhost change (#17275)
  * mono/mono@11e1499c227: [2019-08] [merp] Print missing status marker file for stage 1 (setup) (#17220)
  * mono/mono@7dbad3c3618: [arm] Fix fetching of method addresses (#17253)
  * mono/mono@9a88a36789e: [sgen] Fix invalid value passed to write barrier (#17247)
  * mono/mono@0f241c975ce: [2019-08] Add drawing type converters to mobile profiles (#17240)
  * mono/mono@7ebe1a1763c: Update Roslyn to 3.4.0-beta2-19477-01
  * mono/mono@b759449ba8d: Bump msbuild to track mono-2019-08
  * mono/mono@617f399efca: [IO] Remove read-only logic in mono_w32_get_disk_free_space (#17211)
  * mono/mono@77258ea1122: [2019-08] [debugger][exception] Debugger breaks on handled exceptions (#17202)
  * mono/mono@f83c321f88f: Bump msbuild to track mono-2019-08 (#17193)
  * mono/mono@1ecd094b44c: [2019-08] [Mono.Debugger.Soft] Fix VirtualMachine detaching (#17077)
  * mono/mono@54a33be9dee: [merp] Put thread into async context before running summarizer (#17197)
  * mono/mono@72128bb00d3: Bump libgdiplus to 6.0.4
  * mono/mono@65a972c0333: Always do copy_stack_data on entering GC safe/unsafe mode. (#17184)
  * mono/mono@9e6def1553b: [merp] exit_status is 0 if we ran the uploader successfully (#17187)
  * mono/mono@8a707cc0124: [2019-08] [reflection] Only duplicate MonoMarshalSpec strings for custom types (#17189)
  * mono/mono@bd72952cf82: [2019-08] [merp] Don't overrun buffer in copy_summary_string_safe … (#17178)
  * mono/mono@b6efc0cc906: Bump msbuild to track xplat-master (#17132)
  * mono/mono@2869cd5f67e: Bump ikvm to get mono/ikvm-fork#13 (#17170)
  * mono/mono@a64a25695d6: [2019-08] [merp] Use macOS version not Darwin version in MERP reports (#17147)
  * mono/mono@57f068438d4: [2019-08] [merp] Add API method that whitelists all native libraries (#17128)
jonpryor pushed a commit that referenced this issue Oct 16, 2019
Changes: https://github.com/mono/mono/compare/528103728fc2aedb7b6062e11255d39a0ed3f31c... df5e13f95df7a2d11d86904e74b1bd8950c9d43b

Fixes: #3726

Context: mono/mono@0f241c9
Context: mono/mono#7377
Context: mono/mono#16570
Context: mono/mono#17004
Context: mono/mono#17151
Context: mono/mono#17180

  * mono/mono@df5e13f95df: [tests] Bump corefx to get Azure testhost change (#17275)
  * mono/mono@11e1499c227: [2019-08] [merp] Print missing status marker file for stage 1 (setup) (#17220)
  * mono/mono@7dbad3c3618: [arm] Fix fetching of method addresses (#17253)
  * mono/mono@9a88a36789e: [sgen] Fix invalid value passed to write barrier (#17247)
  * mono/mono@0f241c975ce: [2019-08] Add drawing type converters to mobile profiles (#17240)
  * mono/mono@7ebe1a1763c: Update Roslyn to 3.4.0-beta2-19477-01
  * mono/mono@b759449ba8d: Bump msbuild to track mono-2019-08
  * mono/mono@617f399efca: [IO] Remove read-only logic in mono_w32_get_disk_free_space (#17211)
  * mono/mono@77258ea1122: [2019-08] [debugger][exception] Debugger breaks on handled exceptions (#17202)
  * mono/mono@f83c321f88f: Bump msbuild to track mono-2019-08 (#17193)
  * mono/mono@1ecd094b44c: [2019-08] [Mono.Debugger.Soft] Fix VirtualMachine detaching (#17077)
  * mono/mono@54a33be9dee: [merp] Put thread into async context before running summarizer (#17197)
  * mono/mono@72128bb00d3: Bump libgdiplus to 6.0.4
  * mono/mono@65a972c0333: Always do copy_stack_data on entering GC safe/unsafe mode. (#17184)
  * mono/mono@9e6def1553b: [merp] exit_status is 0 if we ran the uploader successfully (#17187)
  * mono/mono@8a707cc0124: [2019-08] [reflection] Only duplicate MonoMarshalSpec strings for custom types (#17189)
  * mono/mono@bd72952cf82: [2019-08] [merp] Don't overrun buffer in copy_summary_string_safe … (#17178)
  * mono/mono@b6efc0cc906: Bump msbuild to track xplat-master (#17132)
  * mono/mono@2869cd5f67e: Bump ikvm to get mono/ikvm-fork#13 (#17170)
  * mono/mono@a64a25695d6: [2019-08] [merp] Use macOS version not Darwin version in MERP reports (#17147)
  * mono/mono@57f068438d4: [2019-08] [merp] Add API method that whitelists all native libraries (#17128)
jonpryor added a commit that referenced this issue Oct 17, 2019
Changes: mono/mono@5281037...3eb5f34

Fixes: #3726

Context: mono/mono@0f241c9
Context: mono/mono#7377
Context: mono/mono#16570
Context: mono/mono#17004
Context: mono/mono#17151
Context: mono/mono#17180

  * mono/mono@3eb5f34f541: [GTK] Bump bockbuild for GtkViewport autoscrolling patch. (#17321)
  * mono/mono@b601371d5f0: Update MERP event type to MonoAppCrash
  * mono/mono@6184ff007b2: [2019-08][ci] Use Xcode11.1 and 11.2beta2 for XI/XM Mono SDK builds (#17324)
  * mono/mono@8969f2cc99b: [2019-08] [merp] Include any managed methods in the 'unmanaged_frames' portion (#17316)
  * mono/mono@30094401081: [2019-08][merp] Don't install SIGTERM handler in EnableMicrosoftTelemetry (#17308)
  * mono/mono@df5e13f95df: [tests] Bump corefx to get Azure testhost change (#17275)
  * mono/mono@11e1499c227: [2019-08] [merp] Print missing status marker file for stage 1 (setup) (#17220)
  * mono/mono@7dbad3c3618: [arm] Fix fetching of method addresses (#17253)
  * mono/mono@9a88a36789e: [sgen] Fix invalid value passed to write barrier (#17247)
  * mono/mono@0f241c975ce: [2019-08] Add drawing type converters to mobile profiles (#17240)
  * mono/mono@7ebe1a1763c: Update Roslyn to 3.4.0-beta2-19477-01
  * mono/mono@b759449ba8d: Bump msbuild to track mono-2019-08
  * mono/mono@617f399efca: [IO] Remove read-only logic in mono_w32_get_disk_free_space (#17211)
  * mono/mono@77258ea1122: [2019-08] [debugger][exception] Debugger breaks on handled exceptions (#17202)
  * mono/mono@f83c321f88f: Bump msbuild to track mono-2019-08 (#17193)
  * mono/mono@1ecd094b44c: [2019-08] [Mono.Debugger.Soft] Fix VirtualMachine detaching (#17077)
  * mono/mono@54a33be9dee: [merp] Put thread into async context before running summarizer (#17197)
  * mono/mono@72128bb00d3: Bump libgdiplus to 6.0.4
  * mono/mono@65a972c0333: Always do copy_stack_data on entering GC safe/unsafe mode. (#17184)
  * mono/mono@9e6def1553b: [merp] exit_status is 0 if we ran the uploader successfully (#17187)
  * mono/mono@8a707cc0124: [2019-08] [reflection] Only duplicate MonoMarshalSpec strings for custom types (#17189)
  * mono/mono@bd72952cf82: [2019-08] [merp] Don't overrun buffer in copy_summary_string_safe … (#17178)
  * mono/mono@b6efc0cc906: Bump msbuild to track xplat-master (#17132)
  * mono/mono@2869cd5f67e: Bump ikvm to get mono/ikvm-fork#13 (#17170)
  * mono/mono@a64a25695d6: [2019-08] [merp] Use macOS version not Darwin version in MERP reports (#17147)
  * mono/mono@57f068438d4: [2019-08] [merp] Add API method that whitelists all native libraries (#17128)
jonpryor added a commit that referenced this issue Oct 28, 2019
@brendanzagaeski
Copy link
Contributor

Release status update

Thanks for reporting this issue! A new Preview version has now been published that includes the fix for this item. The fix is not yet included in a Release version. I will update this item again when a Release version is available that includes the fix.

Fix included in Xamarin.Android 10.1.0.29.

Fix included on Windows in Visual Studio 2019 version 16.4 Preview 3. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview.

Fix included on macOS in Visual Studio 2019 for Mac version 8.4 Preview 2. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.

@brendanzagaeski
Copy link
Contributor

Release status update

A new Release version has now been published that includes the fix for this item.

Fix included in Xamarin.Android 10.0.6.2.

Fix included on Windows in Visual Studio 2019 version 16.3.8. To get the new version that includes the fix, check for the latest updates or install the latest version from https://visualstudio.microsoft.com/downloads/.

Fix included on macOS in Visual Studio 2019 for Mac version 8.3.7. To get the new version that includes the fix, check for the latest updates on the Stable updater channel.

akoeplinger added a commit to akoeplinger/xamarin-android that referenced this issue Dec 3, 2019
akoeplinger added a commit to akoeplinger/xamarin-android that referenced this issue Dec 3, 2019
jonpryor pushed a commit that referenced this issue Dec 4, 2019
Context: #3726

Add a regression test for Issue #3726 and
`TypeDescriptor.GetConverter(typeof(Color)).ConvertFromString("#FFAAEE")`.
jonpryor pushed a commit that referenced this issue Dec 12, 2019
Context: #3726

Add a regression test for Issue #3726 and
`TypeDescriptor.GetConverter(typeof(Color)).ConvertFromString("#FFAAEE")`.
@ghost ghost locked as resolved and limited conversation to collaborators Jun 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: Mono Runtime Mono-related issues: BCL bugs, AOT issues, etc. bug Component does not function as intended. vs-sync For internal use only; creates a VSTS "mirror" issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants