This project is read-only.

How to add Url address?

Topics: User Forum
Jan 8, 2007 at 10:23 AM
I try to add a Url address in contact item and I get each time a UriFormatException.

Here's my code:

Uri url = new Uri(@"");
contact.Urls.Add(url, PropertyLabels.Personal);

What is wrong?

Jan 8, 2007 at 12:34 PM
I have found this:

UriBuilder UrlBld = new UriBuilder(@"");

but I don't now if is it correct.
Jan 9, 2007 at 1:21 AM
This discussion has been copied to Work Item 7126. You may wish to continue further discussion there.
Jan 9, 2007 at 1:33 AM
The examples you posted should work. Can you give me the callstack where the exception is propagating from?

There is a bug where Uris put into the contact through the SetString methods may be retrieved incorrectly. I had the same bug in the Photos URL parsing code, which was causing your other issue before, but I missed fixing it in this case.

I just now checked in the fix for the above issue. Can you try the new sources and see if that maybe addresses your problem?
Jan 10, 2007 at 12:47 PM
Yes, it's right.

If url is "" or "", it's ok.

But, if url is "", I get a exception UriFormatException.

I think url given is checked before to add collection.

But when I read url from contact item, I get only
"" ( not "" ).

Jan 10, 2007 at 8:37 PM
Hmm... I'm not doing any extra validation of the URL before I store it in the contact. That's why I am using the URri class, so it will perform all the validation for me :)

I suspect that it's the Uri constructor that's actually throwing the exception, rather than the Contact code.