473,399 Members | 3,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Clipboard.GetDataObject();

Hi,

No matter what I have in clipboard Clipboard.GetDataObject(); returns null.
I suspect it might be a problem with Vista or VS2008 IDE debug mode problem?

Is there any way to track why the following statement is always null?

IDataObject iData = Clipboard.GetDataObject();

Thank you,
Max
Jul 2 '08 #1
5 9734
Hi Max,

Where do you run this code snippet? Have you tried to run your application
as elevated in Vista? I suspect this issue is caused by the security
enhancement of Vista.

Can you provide detailed steps for me to reproduce it locally? Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 2 '08 #2
Hi Jeffry,

Here is the steps to reproduce the problem:

1) use visual studio 2008 team system on windows vista sp1
2) Run the following code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AdjustClipboard
{
class Program
{
static void Main(string[] args)
{
IDataObject iData = Clipboard.GetDataObject();

string s = Clipboard.GetData(DataFormats.Text).ToString();
}
}
}
3) you will get null exception!

Thank you for help,
Max

""Jeffrey Tan[MSFT]"" <je***@online.microsoft.comwrote in message
news:vu**************@TK2MSFTNGHUB02.phx.gbl...
Hi Max,

Where do you run this code snippet? Have you tried to run your application
as elevated in Vista? I suspect this issue is caused by the security
enhancement of Vista.

Can you provide detailed steps for me to reproduce it locally? Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
Jul 2 '08 #3
The documentation on MSDN says you need the [STAThreadAttribute()] on main
to use the call to GetDataObject(). With that change, your code worked fine
for me on Vista (Home Edition).
"Max2006" <al*******@newsgroup.nospamwrote in message
news:DF**********************************@microsof t.com...
Hi Jeffry,

Here is the steps to reproduce the problem:

1) use visual studio 2008 team system on windows vista sp1
2) Run the following code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AdjustClipboard
{
class Program
{
static void Main(string[] args)
{
IDataObject iData = Clipboard.GetDataObject();

string s = Clipboard.GetData(DataFormats.Text).ToString();
}
}
}
3) you will get null exception!

Thank you for help,
Max

""Jeffrey Tan[MSFT]"" <je***@online.microsoft.comwrote in message
news:vu**************@TK2MSFTNGHUB02.phx.gbl...
>Hi Max,

Where do you run this code snippet? Have you tried to run your
application
as elevated in Vista? I suspect this issue is caused by the security
enhancement of Vista.

Can you provide detailed steps for me to reproduce it locally? Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you.
Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

================================================= =
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
================================================= =
This posting is provided "AS IS" with no warranties, and confers no
rights.
Jul 2 '08 #4
Hi Max,

Thanks for your feedback, yes, I can reproduce this behavior.

I think "Family Tree Mike" has kindly pointed out the root cause. We need
STAThreadAttribute[] on the Main method, or an exception will throw. This
requirement is documented in the MSDN link below:
http://msdn.microsoft.com/en-us/libr...lipboard.getda
taobject.aspx

Once you added STAThreadAttribute, it should work well. I tested this on my
Vista Enterprise SP1 machine, it works well. Below is the test code:

[STAThread]
static void Main()
{
IDataObject iData = Clipboard.GetDataObject();
string s = Clipboard.GetData(DataFormats.Text).ToString();
MessageBox.Show(s);
}
Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=========================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 3 '08 #5
WOW, That was a neat point. Thank you very much for help

"Family Tree Mike" <Fa************@ThisOldHouse.comwrote in message
news:93**********************************@microsof t.com...
The documentation on MSDN says you need the [STAThreadAttribute()] on main
to use the call to GetDataObject(). With that change, your code worked
fine for me on Vista (Home Edition).
"Max2006" <al*******@newsgroup.nospamwrote in message
news:DF**********************************@microsof t.com...
>Hi Jeffry,

Here is the steps to reproduce the problem:

1) use visual studio 2008 team system on windows vista sp1
2) Run the following code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AdjustClipboard
{
class Program
{
static void Main(string[] args)
{
IDataObject iData = Clipboard.GetDataObject();

string s = Clipboard.GetData(DataFormats.Text).ToString();
}
}
}
3) you will get null exception!

Thank you for help,
Max

""Jeffrey Tan[MSFT]"" <je***@online.microsoft.comwrote in message
news:vu**************@TK2MSFTNGHUB02.phx.gbl...
>>Hi Max,

Where do you run this code snippet? Have you tried to run your
application
as elevated in Vista? I suspect this issue is caused by the security
enhancement of Vista.

Can you provide detailed steps for me to reproduce it locally? Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments
and
suggestions about how we can improve the support we provide to you.
Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

================================================ ==
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach
the
most efficient resolution. The offering is not appropriate for
situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are
best
handled working with a dedicated Microsoft Support Engineer by
contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
================================================ ==
This posting is provided "AS IS" with no warranties, and confers no
rights.
Jul 3 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Joshua Campbell | last post by:
I am working on an application that needs to parse out data that has been copied into the clipboard. My first questions are how can I detect if the clipboard is empty, and how can I empty the...
3
by: Scott Friedrich | last post by:
Hi group I am using a 3rd party AX control in a VB.NET application. One of the methods of this control is to capture the current map within the control to the windows clipboard as .WMF. I am...
2
by: fred | last post by:
I am trying to Copy and paste using a custom format but I canot retrieve the data. In the main Form's class I have declared: Dim myDocmanFormat as DataFormats.Format then in the New Sub of...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
6
by: Ed Bitzer | last post by:
Appreciate some help. Want to continuously check clipboard and if text present unhide and display in a text. The following code can find nothing in the clipboard even though I paste information...
3
by: NoDozing | last post by:
Trying load an embedded object to the clipboard and then save it to a file. When I try and save to the file, I'm getting a "Object reference not set to an instance of an object". I've marked the line...
7
by: Newbie | last post by:
How do I clear the clipboard in VB.NET 2003? TIA Newbie
5
by: nagar | last post by:
I have a .NET 2.0 application that needs to backup and restore the contents of the clipboard. When I back it up, I use this code: DataObject oldClipboard = Clipboard.GetDataObject();...
2
by: asmapanjabi | last post by:
am using C#.net 1.1 while using clipboard m geeting this exception System.Threading.ThreadStateException: Current thread must be set to single thread apartment (STA) mode before OLE calls can be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.