4 Replies - 6558 Views - Last Post: 04 October 2010 - 05:15 PM Rate Topic: -----

#1 daydr3am3r  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 101
  • Joined: 10-April 09

Error while trying to clear clipboard in Windows 7 and C# 3.5

Posted 01 October 2010 - 04:01 PM

Hi
I'm having a stupid problem trying to clear the clipboard in C# 3.5 on Windows 7 - every time I do this the explorer crashes.
At first I didn't know my application is causing this so I spent about a week and a half trying to find the problem.
In the end, a guy from MS forum "remembered" that Windows 7 has a bug that causes explorer.exe to crash every time you try to manipulate the clipboard :|. Apparently Firefox had the same problem a while ago.
At first I tried the simple way: Clipboard.Clear();
Since this was causing the crash I decided to add a control var so that I can check if the clipboard is empty or not:
bool full_clipboard_view = false;

private void txtLic_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (txtLic.Text != "")
            {
                full_clipboard_view = true;
                this.txtLic.SelectAll();
                Clipboard.SetText(this.txtLic.Text);
            }

            else
                MessageBox.Show("Please select an item first!");
        }

private void btnClose_Click(object sender, EventArgs e)
        {
            if (full_clipboard_view == true)
                Clipboard.Clear();

            this.Close();
        }


This also didn't solve my problem so I decided to suspend this part for awhile.
Now I'm almost done with this app and I still cant find a way to fix this.
Did anyone encounter this problem before?

Is This A Good Question/Topic? 0
  • +

Replies To: Error while trying to clear clipboard in Windows 7 and C# 3.5

#2 elbielefeld  Icon User is offline

  • D.I.C Head

Reputation: 70
  • View blog
  • Posts: 216
  • Joined: 18-May 10

Re: Error while trying to clear clipboard in Windows 7 and C# 3.5

Posted 02 October 2010 - 12:01 AM

Hi,

no problems here with just 2 buttons:

        private void button1_Click(object sender, EventArgs e)
        {
            Clipboard.SetText("some text");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Clipboard.Clear();
        }


Was This Post Helpful? 0
  • +
  • -

#3 daydr3am3r  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 101
  • Joined: 10-April 09

Re: Error while trying to clear clipboard in Windows 7 and C# 3.5

Posted 02 October 2010 - 03:12 AM

I don't know what to say. I tested my app on 4 PCs all running Win7 Pro (2 with x64 and 2 with x86). Also tested on Windows Vista and XP in virtual box and had no problem there. Only on Win7 It happens.
But the problem does no appear when I debug, it appears when I run the app outside VS. When I click the close button that also contains ClipboardClear() explorer crashes. And it keeps on doing it till I restart the system.

Here's a part of the discussion I had with MS tech guy:

Quote

Your app, which doesn't load any code into explorer's address space, should not directly be causing it to crash. It is not the fault of your app that explorer is crashing. Rather, it seems that you have stumbled across a bug in Windows Explorer, similar to the Firefox 3.5.x case where the Private Browsing Mode was clearing out the clipboard (much like you seem to be doing) when Firefox would exit. This would cause heap corruption and an ultimate crash, in explorer.exe.

More details about this bug in explorer can be found at https://bugzilla.moz....cgi?id=518412.

This post has been edited by daydr3am3r: 02 October 2010 - 03:26 AM

Was This Post Helpful? 0
  • +
  • -

#4 elbielefeld  Icon User is offline

  • D.I.C Head

Reputation: 70
  • View blog
  • Posts: 216
  • Joined: 18-May 10

Re: Error while trying to clear clipboard in Windows 7 and C# 3.5

Posted 03 October 2010 - 02:00 PM

Can you post the full code?
Was This Post Helpful? 0
  • +
  • -

#5 daydr3am3r  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 101
  • Joined: 10-April 09

Re: Error while trying to clear clipboard in Windows 7 and C# 3.5

Posted 04 October 2010 - 05:15 PM

Well that's all.
When I double click the textbox, if the text box is not empty, it sets the control var to true, meaning that the clipboard is not empty and it copies the text to clipboard.
When I close the form by clicking the CLOSE button(the control box it's disabled) it clears the clipboard.
If you want me to post the entire code for that form it's OK with me but I don't see how that will help.
However I just realized I forgot to convert to string :death:
I'll correct that and post back.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1