codebrothers.net :: Home  >  Matthias Denkmaier
User: Guest  Login
Matthias Denkmaier
C# - what else?
Blog search:  
ArgumentNullException when calling Clipboard.SetText

The following code throws an error with a misleading error message:


string text = “”;
if(text != null )
{
     Clipboard.SetText( text, TextDataFormat.Text );
}

 

System.ArgumentNullException: The value must not be NULL.
Parametername: text
   at System.Windows.Forms.Clipboard.SetText(String text, TextDataFormat format)

 

When you call the method Clipboard.SetText( String text, TextDataFormat format) you also have to check, that the given text is not empty. Otherwise you also get this message, even if it just says, that the value must not be Null.

 

Share this post: Email it!
Posted:  2/8/2007 8:50:51 PM  by  mdenkmaier
Tags:  C#Development
No comments, yet!
Leave a Comment

Name required

Your URL

Comments (required)