You receive a "The process cannot access the file because it is being used by another process" when you try to remove an image file from Solution Explorer in Visual Studio .NET 2002 and 2003 (810110)



The information in this article applies to:

  • Microsoft Common Language Runtime (included with the .NET Framework 1.1)
  • Microsoft Common Language Runtime (included with the .NET Framework) 1.0
  • Microsoft Visual Studio .NET (2003), Professional Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2003), Academic Edition
  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2002), Academic Edition

SYMPTOMS

When you try to remove an image file from Solution Explorer in Microsoft Visual Studio .NET 2002 or 2003, you receive the following error message:
Error deleting file 'ImageFileName'. The process cannot access the file because it is being used by another process.

CAUSE

This problem occurs when a reference to the image is created and then the reference is later removed.

For example, the Image property of a PictureBox control is set to the image file. Later, the PictureBox control is removed from the Windows form. When you try to remove the image that was referenced in the PictureBox control, you receive an error message.

Note To perform Undo operations, Visual Studio .NET Designer may keep a lock on an image file where a reference is created and then is later removed.

WORKAROUND

To work around this problem, you must remove all references to the image and then restart Visual Studio .NET. After you restart Visual Studio .NET, you can remove the image file from Solution Explorer.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Steps to reproduce the behavior

  1. Start Visual Studio .NET.
  2. On the File menu, click New, click Project, and then click Visual Basic Projects.
  3. Click Windows Application, type YourApplicationName in the Name box, and then click OK.

    Note Replace YourApplicationName with the name of your application.
  4. From Windows Explorer, copy an image file to Solution Explorer to add the image to the solution.
  5. Add a PictureBox control to the Windows form.
  6. Set the Image property of the PictureBox control to the image file that you added in step 4.
  7. On the File menu, click Save All.
  8. Delete the PictureBox control that you added in step 6 from the Windows form.
  9. In Solution Explorer, right-click the image file, and then click Delete.
  10. Click OK to confirm the deletion.
For more information about how to use Solution Explorer in Visual Studio .NET, visit the following Microsoft Developer Network (MSDN) Web site:

Modification Type:MajorLast Reviewed:1/5/2005
Keywords:kbGDIPlus kbtshoot kbprb KB810110 kbAudDeveloper