Help topic for PropertyItem class is not complete (821623)



The information in this article applies to:

  • Microsoft .NET Framework 1.1
  • Microsoft .NET Framework 1.0
  • Microsoft Visual Basic .NET (2003)
  • Microsoft Visual Basic .NET (2002)
  • Microsoft Visual C# .NET (2003)
  • Microsoft Visual C# .NET (2002)

SUMMARY

In the Microsoft .NET Framework Class Library documentation, the help topic for the PropertyItem class is not complete.

For more information, visit the following Microsoft Web site:

MORE INFORMATION

The existing documentation states the following:

Encapsulates a metadata property to be included in an image file. Not inheritable.

The documentation should also state the following:

A PropertyItem is not intended to be used as a stand-alone object. A PropertyItem object is intended to be used by classes that are derived from System.Drawing.Image. A PropertyItem object is used to retrieve and to change the metadata of existing image files, not to create the metadata. Therefore, the PropertyItem class does not have a defined Public constructor, and you cannot create an instance of a PropertyItem object.

To work around the missing Public constructor, use an existing PropertyItem object instead of creating a new instance of the PropertyItem class. To do this, use the following sample code:

Visual Basic .NET sample code

' Create an Image to gain access to an existing PropertyItem object from.
Dim MyImage As System.Drawing.Image = Image.FromFile("C:\Sample.jpg") ' Refer to some existing .JPEG image.

' Define a PropertyItem variable.
Dim pItem As System.Drawing.Imaging.PropertyItem

' Instead of creating a new instance of PropertyItem, use an existing PropertyItem object.
For Each pItem In MyImage.PropertyItems
   ' Obtain a reference to the first PropertyItem object of MyImage, and then exit the loop.
   Exit For
Next

' You may modify and use the pItem object now.

Visual C# .NET sample code

// Create an Image to gain access to an existing PropertyItem object from.
System.Drawing.Image MyImage = Image.FromFile("C:\\Sample.jpg");  // Refer to some existing .JPEG image.

// Instead of creating a new instance of PropertyItem, use an existing PropertyItem object.
foreach (System.Drawing.Imaging.PropertyItem pItem in MyImage.PropertyItems)
{
   // Obtain a reference to the first PropertyItem object of MyImage, and then exit the loop.
   break;
}

// You may modify and use the pItem object now.
Note For this code to work correctly, you must have a reference to the System.Drawing.dll assembly.

REFERENCES

For more information, click the following article number to view the article in the Microsoft Knowledge Base:

814358 PRB: Compile error when you try to create an instance of System.Drawing.Imaging.PropertyItem


Modification Type:MinorLast Reviewed:2/24/2006
Keywords:kbvs2005doesnotapply kbvs2005swept kbvs2002sp1sweep kbBug kbDocs kbSample kbGDIPlus kbgdipimaging kbdraw kbProgramming kbdocfix kbdocerr KB821623 kbAudDeveloper