473,791 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Clipboard.GetDa taObject();

Hi,

No matter what I have in clipboard Clipboard.GetDa taObject(); 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.GetDa taObject();

Thank you,
Max
Jul 2 '08 #1
5 9786
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****@microsof t.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.Collecti ons.Generic;
using System.Linq;
using System.Text;
using System.Windows. Forms;

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

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

Thank you for help,
Max

""Jeffrey Tan[MSFT]"" <je***@online.m icrosoft.comwro te in message
news:vu******** ******@TK2MSFTN GHUB02.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****@microsof t.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 [STAThreadAttrib ute()] on main
to use the call to GetDataObject() . With that change, your code worked fine
for me on Vista (Home Edition).
"Max2006" <al*******@news group.nospamwro te in message
news:DF******** *************** ***********@mic rosoft.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.Collecti ons.Generic;
using System.Linq;
using System.Text;
using System.Windows. Forms;

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

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

Thank you for help,
Max

""Jeffrey Tan[MSFT]"" <je***@online.m icrosoft.comwro te in message
news:vu******** ******@TK2MSFTN GHUB02.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****@microsof t.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
STAThreadAttrib ute[] 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 STAThreadAttrib ute, 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.GetDa taObject();
string s = Clipboard.GetDa ta(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****@microsof t.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.c omwrote in message
news:93******** *************** ***********@mic rosoft.com...
The documentation on MSDN says you need the [STAThreadAttrib ute()] on main
to use the call to GetDataObject() . With that change, your code worked
fine for me on Vista (Home Edition).
"Max2006" <al*******@news group.nospamwro te in message
news:DF******** *************** ***********@mic rosoft.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.Collecti ons.Generic;
using System.Linq;
using System.Text;
using System.Windows. Forms;

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

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

Thank you for help,
Max

""Jeffrey Tan[MSFT]"" <je***@online.m icrosoft.comwro te in message
news:vu******* *******@TK2MSFT NGHUB02.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****@microsof t.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
professiona l 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
6608
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 clipboard? I tried the code below, but it didn't seem to tell me if the clipboard was empty. If Clipboard.GetDataObject() Is Nothing Then MessageBox.Show("Clipboard is empty") Else Dim txtdata As IDataObject = Clipboard.GetDataObject() If...
3
6776
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 automating some precesses for the client and I don't know how to programmatically paste the WMF from the clipboard to another control in the application. The picture box control supports WMF but I don't know how to set its image property to whats in...
2
3895
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 the main form I have: myDocmanFormat = DataFormats.GetFormat("DocmanFormat")
7
11641
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 is proving to be more difficult. These pictureboxes are bound to an AccessDB. If the user wants to add an image, they select an image using an OpenFileDialog: Dim result As DialogResult = Pic_Sel.ShowDialog() If (result = DialogResult.OK) Then
6
3962
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 there from Notepad. \\ Public Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click Dim t As New System.Timers.Timer(2000) AddHandler t.Elapsed, AddressOf TimerFired t.Enabled = True End Sub
3
6586
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 with ---->>> where the error occurs. Any help would be appreciated. Dim InShapeObj As Word.InlineShape Dim SaveObj As New DataObject Dim ImageObj As Image Dim WordApp As New Word.ApplicationClass...
7
3852
by: Newbie | last post by:
How do I clear the clipboard in VB.NET 2003? TIA Newbie
5
3449
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(); IDataObject prevClipboard = new DataObject(); string formats; formats = oldClipboard.GetFormats(); //gets all the possible formats
2
2125
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 made. Ensure that your Main function has STAThreadAttribute marked on it. at System.Windows.Forms.Clipboard.GetDataObject()
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10426
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10154
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9993
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2913
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.