5

I'm creating a Uri object in Mono (under unix system), this is very simple(like in VStudio/Windows): new Uri("http://my.url_here.com/"). Then I'm creating another system object which use the Uri: HttpSelfHostConfiguration().

In the source code of HttpSelfHostConfiguration, the received Uri will be validated using the following if statement(checked in Mono sources):

if (!ReferenceEquals(baseAddress.Scheme, Uri.UriSchemeHttp) && !ReferenceEquals(baseAddress.Scheme, Uri.UriSchemeHttps))
    {
        throw Error.ArgumentUriNotHttpOrHttpsScheme("baseAddress", baseAddress);
    }

and the "if" fails because "ReferenceEquals(baseAddress.Scheme, Uri.UriSchemeHttp)" return false, means that for Mono(running in Unix) baseAddress.Scheme is not equal to Uri.UriSchemeHttp.

Notice that is confirmed debugging in Mono(Unix) that: baseAddress.Scheme = "http" and Uri.UriSchemeHttp = "http".

Under VStudio this works perfect.

Can anyone help me understand how ReferenceEqual works under Mono(Unix) and, most important, how can I create a valid Uri in Mono that pass the validation with the if statement above ??

thanks a lot

user810917
  • 241
  • 4
  • 12
  • I don't understand why you need the references to be identical, rather than just the string values? – Matthew Watson Sep 24 '13 at 09:50
  • I'm not trying to compare anything. I'm just trying to Create an instance of HttpSelfHostConfiguration() which receive an string or Uri in constructor. This creation fails because looking in source code there is a validation of uri address using if statement in my question. I'm wondering why this statement fails under Mono/Unix if it works under VStudio/Windows. basically the point is when comparing two string "http", one the Uri.Scheme, the other the constant Uri.UriSchemeHttp – user810917 Sep 24 '13 at 10:00
  • If anyone can test under Mono/Unix the following statement: var config = new HttpSelfHostConfiguration(new Uri("http ://any.url.com/")) (spaces are just to show full url here); I just receive exception "Unsupported URI scheme" – user810917 Sep 24 '13 at 10:02

0 Answers0