Home > Blockchain >  NSUrl throws exception
NSUrl throws exception

Time:11-15

In my Xamarin.iOS app, I have this code:

using (var url = new NSUrl(uri))
{
    // some code
}

It was working before, but when I create the new NSUrl(uri) it throws an exception with the message:

Could not initialize an instance of the type 'Foundation.NSUrl': the native 'initWithString:' method returned nil. It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false.

My uri is something like this: https://myappdev.blob.core.windows.net/myimages/apples/auth0|5db82ec6a5ee570c97cd5465.jpg?1666895662894

When I paste uri into my browser I get an image. (the url above is an example so you won't get an image if you try to download it)

CodePudding user response:

I can reproduce your issue in Xamarin.ios and get the same error.

I noticed that a special character "|" in your url. Seems the error was due to this special character.

And after I changed "|" to "%" then the error disappeared.

  • Related