Bug 18009 - HttpUtility.UrlEncode throws error for JSON type string when we SELECT option to include MONO in application bundle
Summary: HttpUtility.UrlEncode throws error for JSON type string when we SELECT option...
Status: RESOLVED ANSWERED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: mmp ()
Version: 1.6.19
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: 2.4.0 (C6)
Assignee: timothy.risi
URL:
Depends on:
Blocks:
 
Reported: 2014-02-26 02:44 UTC by sujit
Modified: 2015-03-24 12:42 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
full project solution added (62 bytes, text/plain)
2014-02-26 02:52 UTC, sujit
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description sujit 2014-02-26 02:44:32 UTC
Hi,

I am finding this strange. 

HttpUtility.UrlEncode throws error when I run project after selecting "INCLUDE MONO RUNTIME IN APPLICATION BUNDLE" through project options > Max OS X Packaging. I have attached project, and code is written in awakeFromNib. Can you check and confirm and suggest me resolution for this?


My Xamarin studio details are as under
=== Xamarin Studio ===

Version 4.2.3 (build 59)
Installation UUID: fdf8d74f-4fcb-4e5d-95fe-2a01818f1443
Runtime:
	Mono 3.2.6 ((no/9b58377)
	GTK+ 2.24.23 theme: Raleigh
	GTK# (2.12.0.0)
	Package version: 302060000

=== Apple Developer Tools ===

Xcode 5.0.2 (3335.32)
Build 5A3005

=== Xamarin.iOS ===

Not Installed

=== Xamarin.Android ===

Not Installed

=== Xamarin.Mac ===

Xamarin.Mac: 1.6.27

=== Build Information ===

Release ID: 402030059
Git revision: 828c2a91b515daaac7e57bc69fcfda6178d4ec01
Build date: 2014-02-18 18:05:23+0000
Xamarin addins: 3bdcc713bdc4b0c04973f3a31b6d47ad3e205962

=== Operating System ===

Mac OS X 10.9.1
Darwin BL-55.local 13.0.0 Darwin Kernel Version 13.0.0
    Thu Sep 19 22:22:27 PDT 2013
    root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64

==================================

Thanks.
Comment 1 sujit 2014-02-26 02:52:33 UTC
Created attachment 6151 [details]
full project solution added
Comment 2 Aaron Bockover [MSFT] 2014-02-26 11:52:22 UTC
This is happening because the linker is removing the default constructor on System.Web.Configuration.WebConfigurationHost, which is an internal implementation detail. System.Configuration in general is not supported. We may fix this in a future release.

As an immediate fix you should try escaping your string with System.Uri.EscapeDataString or System.Uri.EscapeUriString (see [1] for a good explanation on which one to use given your scenario). These methods are preferred anyway as they do not require a reference to the large System.Web assembly.

[1] http://blogs.msdn.com/b/yangxind/archive/2006/11/09/don-t-use-net-system-uri-unescapedatastring-in-url-decoding.aspx)

Exception for future reference:

System.MissingMethodException: Default constructor not found for type System.Web.Configuration.WebConfigurationHost
  at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0 
  at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0 
  at System.Configuration.InternalConfigurationSystem.Init (System.Type typeConfigHost, System.Object[] hostInitParams) [0x00000] in <filename unknown>:0 
  at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x00000] in <filename unknown>:0 
  at System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration (System.String path, System.String site, System.String locationSubPath, System.String server, System.String userName, System.String password, Boolean fweb) [0x00000] in <filename unknown>:0
Comment 3 Timothy Risi 2015-03-24 12:42:21 UTC
We looked into this and use of the linker with assemblies that use system.configration (or System.Web.Configuration in this case) is problematic, with many cases running into problems as you've seen. For our new Unified profile, we've restricting use of the linker only to the mobile profile which does not contain system.web.configuration. We're not planning on changing the classic behavior as of right now.

If you run into other problems like this, either disable the linker on classic or move to Unified mobile.