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 4019306
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:05:18+00:00 2026-05-20T10:05:18+00:00

I made this windows forms application in .net 3.5 (VS c# express) . Now

  • 0

I made this windows forms application in .net 3.5 (VS c# express) .
Now I want to convert it so it can run with just .net 2.0 installed. SO in my project properties: I selected “target framework ” as 2.0 , fixed the errors that I got.

After this the app runs fine with .net 3.0 installed , but won’t run on a fresh install of xp with with .net 2.0 installed. “Application has crashed. send error report”
What do I do ? I want this thing to run under 2.0.

here is the code :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Xml;
using System.Runtime.InteropServices;
using Microsoft.Win32;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {

        int numberOfMatches = 0;

        string[,] data;
        bool update = true ;
        string fileToParse = Path.GetTempPath() + "cricketfile.xml";
        int matchToShow = 0;
        bool showschedule = true ;

        public const int WM_NCLBUTTONDOWN = 0xA1;
        public const int HT_CAPTION = 0x2;

        [DllImportAttribute("user32.dll")]
        public static extern int SendMessage(IntPtr hWnd,
                         int Msg, int wParam, int lParam);
        [DllImportAttribute("user32.dll")]
        public static extern bool ReleaseCapture();

        RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

        public Form1()
        {

            InitializeComponent();

            if (Environment.OSVersion.Version.Major <= 5)
            {
                // MessageBox.Show("xp");
            }
            else
            {
                label1.Top = 1;
                pictureBox1.Top = 1;
            }
            // label1.Left = 1;
            int X = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width / 2 - this.Width / 2;
            this.Location = new System.Drawing.Point(X, -5);


            if (rkApp.GetValue("cricketscore") == null)
            {
                startWithWindowsToolStripMenuItem.Checked = false ;
            }
            else
            {
                startWithWindowsToolStripMenuItem.Checked = true ;
            }
            this.Region = new Region(new Rectangle(10, 10, 197, 17));
            ToolTip tooltip = new ToolTip();
//            MessageBox.Show(" F" + tooltip.AutomaticDelay);
            tooltip.AutomaticDelay = 0;
            tooltip.InitialDelay = 0;
            tooltip.SetToolTip(pictureBox1, " right click for settings, left click to move");
            tooltip.SetToolTip(label1, " right click for settings, left click to move");
            fetchData();
            addContextEntries();
            chooseIndia();
            updateScore();

           // MessageBox.Show(data.GetLength(0).ToString());


            //foreach (string s in data)
            //{
            //    Console.WriteLine(s);
            //}

            timer1.Interval = 20 * 1000;
            timer1.Enabled = true;

        }
        public void addContextEntries()
        {
           // MessageBox.Show("num- " + numberOfMatches);
            List<ToolStripMenuItem> Mylist1 = new List<ToolStripMenuItem>();
            for (int i = 0; i < numberOfMatches; i++)
            {
                Mylist1.Add( new ToolStripMenuItem() );
                this.contextMenuStrip1.Items.Add(Mylist1[i]);
                Mylist1[i].Text = "See Match " + (i + 1) + "'s score";
                switch(i) 
                {
                    case 0:
                        Mylist1[i].Click += new System.EventHandler(this.match1);
                        break;
                    case 1:
                        Mylist1[i].Click += new System.EventHandler(this.match2);
                        break;
                    case 2:
                        Mylist1[i].Click += new System.EventHandler(this.match3);
                        break;
                    case 3:
                        Mylist1[i].Click += new System.EventHandler(this.match4);
                        break;
                    case 4:
                        Mylist1[i].Click += new System.EventHandler(this.match5);
                        break;
                }

            }

        }
        public void match1(object sender, EventArgs e)
        {
           // MessageBox.Show("match 1");
            matchToShow = 0;
            label1.Text = data[0, 0] + " " + data[0, 1];


        }
        public void match2(object sender, EventArgs e)
        {
          //  MessageBox.Show("match 2");
            matchToShow = 1;
            label1.Text = data[1, 0] + " " + data[1, 1];

        }
        public void match3(object sender, EventArgs e)
        {
            matchToShow = 2;
            label1.Text = data[2, 0] + " " + data[2, 1];

        }
        public void match4(object sender, EventArgs e)
        {
            matchToShow = 3;
            label1.Text = data[3, 0] + " " + data[3, 1];

        }
        public void match5(object sender, EventArgs e)
        {
            matchToShow = 4;
            label1.Text = data[4, 0] + " " + data[4, 1];

        }

        public void chooseIndia()
        {
            try
            {
                for (int i = 0; i < data.GetLength(0); i++)
                {
                    // MessageBox.Show("i - " + i);
                    if (data[i, 3].ToLower().Contains("india"))
                    {
                        matchToShow = i;
                      //  MessageBox.Show("i - " + i);
                        break;
                    }
                }
            }
            catch (NullReferenceException ne)
            {

            }
        }
        public void updateScore()
        {
            fetchData();
            if (update == true)
            {
                try
                {
                    label1.Text = data[matchToShow, 0] + " " + data[matchToShow, 1];
                }
                catch (Exception e)
                { 

                }
            }
        }

        public void fetchData()
        {
            int matchnumber = -1;
            numberOfMatches = 0;
            WebClient Client = new WebClient();
            try
            {
              Client.DownloadFile("http://synd.cricbuzz.com/score-gadget/gadget-scores-feed.xml", fileToParse);
            }
            catch (WebException we)
            {
               // if (we.ToString().ToLower().Contains("connect to"))
               // MessageBox.Show("sdf");
                    label1.Text = "No Internet";
                    update = false ;
                    this.Update();
                   // System.Threading.Thread.Sleep(1000);

            }
            try
            {
                XmlTextReader xmlreader0 = new XmlTextReader(fileToParse);
                while (xmlreader0.Read())
                {
                    if (xmlreader0.Name.ToString() == "match" && xmlreader0.NodeType == XmlNodeType.Element)
                    {
                        ++numberOfMatches;
                    }
                }
                data = new string[numberOfMatches, 4];
                // numberOfMatches = 0;
                // MessageBox.Show("matchnumbers - " + numberOfMatches);
               // MessageBox.Show("asd");
                XmlTextReader xmlreader = new XmlTextReader(fileToParse);
                while (xmlreader.Read())
                {
                    // MessageBox.Show("READING");
                    if (xmlreader.Name.ToString() == "header" && xmlreader.NodeType == XmlNodeType.Element)
                    {
                        xmlreader.Read();

                        data[matchnumber, 0] = xmlreader.Value;
                        //  MessageBox.Show(xmlreader.Value);
                    }


                    if (xmlreader.Name == "description" && xmlreader.NodeType == XmlNodeType.Element)
                    {
                        //  MessageBox.Show(xmlreader.Value);
                        xmlreader.Read();
                        //  MessageBox.Show("matched - " + xmlreader.Value);
                        data[matchnumber, 1] = xmlreader.Value;
                    }

                    if (xmlreader.Name == "url-text" && xmlreader.NodeType == XmlNodeType.Element)
                    {
                        xmlreader.Read();
                        // MessageBox.Show(xmlreader.Value);
                        data[matchnumber, 2] = xmlreader.Value;
                    }

                    if (xmlreader.Name == "url-link" && xmlreader.NodeType == XmlNodeType.Element)
                    {
                        xmlreader.Read();
                        data[matchnumber, 3] = xmlreader.Value;
                    }

                    if (xmlreader.Name.ToString() == "match" && xmlreader.NodeType == XmlNodeType.Element)
                    {
                        matchnumber++;
                        showFullScorecardToolStripMenuItem.Text = "Show full scorecard";
                        showschedule = true;
                        update = true;
                    }
                    if (xmlreader.Name.ToString() == "nextlive" && xmlreader.NodeType == XmlNodeType.Element)
                    {
                        label1.Text = "No current match";
                        showFullScorecardToolStripMenuItem.Text = "Show Schedule";
                        showschedule = false;
                        update = false;
                        break;
                    }

                }
                xmlreader.Close();
                xmlreader0.Close();
            }
            catch (FileNotFoundException fe)
            {
                // MessageBox.Show("no internet");
            }

        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            updateScore();
        }

        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ReleaseCapture();
                SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
            }
        }

        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ReleaseCapture();
                SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
            }
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void switchColrosToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if ( label1.ForeColor == System.Drawing.Color.Black)
                label1.ForeColor = System.Drawing.Color.White ;
            else
                label1.ForeColor = System.Drawing.Color.Black; 
        }

        private void startWithWindowsToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void startWithWindowsToolStripMenuItem_CheckStateChanged(object sender, EventArgs e)
        {
            if (startWithWindowsToolStripMenuItem.Checked == true)
            {
                rkApp.SetValue("cricketscore", Application.ExecutablePath.ToString());
            }
            else
            {
                rkApp.DeleteValue("cricketscore", false);
            }
        }

        private void showFullScorecardToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if ( showschedule == true )
                System.Diagnostics.Process.Start(data[matchToShow, 3]);
            else
                System.Diagnostics.Process.Start("http://www.cricbuzz.com/component/cricket_schedule/");
        }

        private void label1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ReleaseCapture();
                SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
            }
        }

        //public void findNumberOfMatches()
        //{
        //    if (xmlreader.Name.ToString() == "match" && xmlreader.NodeType == XmlNodeType.Element)
        //    {
        //        matchnumber++;
        //    }
        //}
    }
}

Thanks

  • 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-20T10:05:19+00:00Added an answer on May 20, 2026 at 10:05 am

    The way it closes doesn’t look like need to upgrade the framework but lets see those:

    • Try to test it under .NET 2.0 with latest .NET 2.0 service pack installed

    • Try to check the references in your project whether they’re all clean to .NET 2.0 or not, sometimes this is not done correctly. Press F4 of every assembly that has 2.0 and 3.x versions to see properties and confirm (and remove/add if needed). If you see anything like LINQ or so, this needs to be removed.

    • Try to bring Visual C# 2005 Express or similar and see if the code compiles under it. Or create new .NET 2.0 project and copy your code to it.

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

Sidebar

Related Questions

I've made a C# windows forms application and want this application to copy itself
I develop on a pretty big windows forms .net (C#) application with several assemblys.
This is the day of weird behavior. We have a Win32 project made with
I'm creating a simple Windows Forms application with NHibernate and I'm a bit confused
I currently have a functioning in-house Windows Forms application which extensively uses the DataGridView
I have previously written user interfaces using .NET and Windows Forms. I'm about to
I have a WCF self-hosted service in a Windows Forms application. I am going
How can I implement following in ASP.NET MVC application: user opens intranet website user
I have the following projects: MVC Console application Class library Windows forms application COM
I am new to .NET, I have made a small app. I want that

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.