user1521582
user1521582

Reputation: 87

An unknown error has occurred 8004005

When i create the basic application in Visual studio for windows phone 2010 to link to a web browser and then type out this

private void button1_Click(object sender, RoutedEventArgs e)
{
    string site = textBox1.Text;    

    webBrowser1.Navigate(new Uri(site, UriKind.Absolute));
}

When i build the application it shows as successful. However when i run debug and the emulator starts. When i press the button to navigate to a certain URL say google.com which is the text that I've mentioned in text box 1 , an error occurs

System.SystemException An unknown error has occurred. Error: 80004005

Upvotes: 2

Views: 1125

Answers (2)

Tawnos
Tawnos

Reputation: 1887

A URI requires a scheme type (e.g. http://). Without that, you are likely ending up with what looks like a relative URI.

Use the URI builder, which defaults to http when no scheme is specified:

UriBuilder builder = new UriBuilder(textBox1.Text);
webBrowser1.Navigate(builder.Uri);

Upvotes: 2

Asif Mushtaq
Asif Mushtaq

Reputation: 13150

The Uri only work with a complete URL start with scheme mentioned like http://www.msn.com I think you should use Uri.TryCreate()

string site = textBox1.Text;
Uri uri;
if (Uri.TryCreate(site, UriKind.Absolute, out uri))
{
    webBrowser1.Navigate(uri);
}

Upvotes: 3

Related Questions