title: How to avoid UriFormatException?
body: <p>I have an application on windows mobile platform cf3.5. This communicates with a web server and they do it nicely, requests get correct replies. 
  However, on every request it throws a System.UriFormatException in visual studio output window. Uris look like this:</p>
  
  <pre><code>http://api/Information/TagKey/4952b9ff-af55-4219-95b8-1ac57a70b7a8/L0011421
  </code></pre>
  
  <p>How can I know what is wrong with these uris? Should I change '-' chars in the guid fields or what?</p>
  
  <p>I build the uri by this method, where uri is the base address of the server and dictionary contains the parameters:</p>
  
  <pre><code>private static string buildUri(string uri, Dictionary&lt;string, string&gt; data)
      {
          StringBuilder _uri = new StringBuilder(uri);
          foreach(KeyValuePair&lt;string, string&gt; item in data) 
          {
              _uri.Append("/" + item.Value);
          }
          return _uri.ToString();
      }
  </code></pre>
  
  <p>This is used by this createRequest method:</p>
  
  <pre><code>private static HttpWebRequest createRequest(string uri, HttpMethods method, Dictionary&lt;string, string&gt; data, Dictionary&lt;string, object&gt; postdata)
      {
          string fullUri = buildUri(uri, data);
          Classes.Log.Write("/// "+fullUri);
          WebRequest request = HttpWebRequest.Create(fullUri);
          request.Method = Enum.ToObject(typeof(HttpMethods), method).ToString();
          request.ContentType = "application/json; charset=utf-8";
          ((HttpWebRequest)request).Accept = "application/json; charset=utf-8";
          request.ContentLength = 0;
          if (method != HttpMethods.GET &amp;&amp; method != HttpMethods.DELETE &amp;&amp; postdata != null)
          {
              Encoding encoding = Encoding.UTF8;
              string postData = buildPostData(postdata, "application/json");
              byte[] byteArray = encoding.GetBytes(postData);
              request.ContentLength = byteArray.Length;
              if (byteArray != null &amp;&amp; byteArray.Length &gt; 0)
              {
                  using (Stream stream = request.GetRequestStream())
                  {
                      stream.Write(byteArray, 0, (int)request.ContentLength);
                  }
              }
          }
          return (HttpWebRequest)request;
      }
  </code></pre>
  
  <p>It throws the exception at</p>
  
  <pre><code>WebResponse response = request.GetResponse();
  </code></pre>
  
  <p>that is in an other method.</p>
  
  <p>I have generated an Uri object first by the string and it doesn't throw any exceptions.</p>