Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6961935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:35:42+00:00 2026-05-27T15:35:42+00:00

What am I doing wrong? I have application, which run normally, but when I

  • 0

What am I doing wrong? I have application, which run normally, but when I press button in Win 7 (search in Google) that assigns

hl.NavigateUri = new Uri("http://www.google.com.ua/#hl=ru&source=hp&biw=1280&bih=933&q=");

it Crashes. What am I doing wrong? On Windows XP SP3 machine it normally works..

private void button1_Click(object sender, RoutedEventArgs e)
{
    try
    {
        bool google = true;

        if (((Button)sender).Content.ToString() == "Google")
            google = true;
        else
            google = false;
        Run run1 = new Run(textBox1.Text);
        Hyperlink hl = new Hyperlink(run1);
        TextBlock tb = new TextBlock();
        //Label label1 = new Label();
        //label1.Content = textBox1.Text;
        //label1.Tag = ;
        if (google)
            hl.NavigateUri = new Uri("http://www.google.com.ua/#hl=ru&source=hp&biw=1280&bih=933&q=");
        else
            hl.NavigateUri = new Uri("http://yandex.ua/yandsearch?text=");
        hl.Tag = i;
        hl.Click += new RoutedEventHandler(hl_Click);
        tb.Inlines.Add(hl);
        tb.Inlines.Add(" ");
        wrapPanel1.Children.Add(tb);
        if (google)
        {
            col1_links.Add("http://www.google.com.ua/#hl=ru&source=hp&biw=1280&bih=933&q=" + HttpUtility.UrlEncode(textBox1.Text));
        }
        else
        {
            col1_links.Add("http://yandex.ua/yandsearch?text=" + HttpUtility.UrlEncode(textBox1.Text));
        }
        col1_texts.Add(textBox1.Text);
        webBrowser1.Navigate(col1_links[i].ToString());
        i++;
        SaveData();
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

I got the following error:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:35:43+00:00Added an answer on May 27, 2026 at 3:35 pm

    I can rewrite your code in a few lines:

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        try
        {
            var google = ((Button)sender).Content.ToString() == "Google";
            var run1 = new Run(textBox1.Text);
            var hl = new Hyperlink(run1)
            {
                NavigateUrl = google ? "http://www.google.com.ua/#hl=ru&source=hp&biw=1280&bih=933&q=" :
                                       "http://yandex.ua/yandsearch?text=";
                Tag = i;
            };
            var tb = new TextBlock();
            hl.Click += new RoutedEventHandler(hl_Click);
            tb.Inlines.Add(hl);
            tb.Inlines.Add(" ");
            wrapPanel1.Children.Add(tb);
            col1_links.Add(hl.NavigateUrl + HttpUtility.UrlEncode(textBox1.Text));
            col1_texts.Add(textBox1.Text);
            webBrowser1.Navigate(col1_links[i].ToString());
            i++;
            SaveData();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
    

    Try to be more professional 😉 . First of all, NavigateUrl is “string” (not Uri), try to use this (not NavigateUri). Second thing is there is no “i” variable, where is it?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe I'm doing something wrong but I have a textarea where I've specified textAlign
I have found out that I am doing WPF wrong and frustratingly must overhaul
I have a web application for iPhone, which will ultimately run within a PhoneGap
I have an application that determines which path of execution to take based on
What am I doing wrong? I have a simple console app in VS08. When
Can someone suggest what I am doing wrong? Basically I have a List Items,
I'm probably doing this all wrong. I have a text file full of data
K... I'm doing something obviously wrong. I have a simple page with a file
I am now doing unit testing on an application which was written over the
I have created an application which inserts data into a SQL database. Basically, from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.