What causes 'The process cannot access the file ... *.pdb' when compiling a MAUI project in Release mode?

dg2k 1,391 Reputation points
2023-04-12T10:06:35.7733333+00:00
  • Visual Studio: Version 17.6.0 Preview 3.0
  • Framework: 8.0.0-preview.1.23110.8
  • Operating System: Windows 11 Enterprise Insider Preview Edition; Version 22H2; OS Build 25336.1000

I am getting this endless compile errors of:
System.IO.IOException: The process cannot access the file 'obj\Release\net8.0-android\android\assets<filename>.pdb' because it is being used by another process.

To give you an example of *pdb files, I had ExoPlayer.pdb and Xamarin.Firebase.Iid.pdb.
When ExoPlayer.pdb was flagged, I unistalled the CommunityToolkit.Maui.MediaElement package if compilation succeeds, but another one popped up -- Xamarin.Firebase.Iid.pdb.

What causes these errors, and what is a workaround?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,888 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,231 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,648 questions
0 comments No comments
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 61,731 Reputation points
    2023-04-12T23:10:46+00:00

    .pdb (debug reference) files are created as part of the build. the error indicates some process has the old file open, so a new one can not be created. you could try to delete the folder first, but it may fail for the same reason. exit programs til the delete works. you can use the openfiles utility to detect which process has the file open:
    https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/openfiles.

    note: will need to run the command as admin


0 additional answers

Sort by: Most helpful