Visual Studio .NET 2003 C# Compile Error CS0042

I am working on a VS.NET 2003 C# web project that contains multiple projects and on occasion I get an annoying fatal build error (CS0042):

Unexpected error creating debug information file ‘<project path>\obj\Debug\<DLL Name>.PDB’: The process cannot access the file because it is being used by another process.

Starting with a Google search led me to many developers having the same or similar problems with the following advice:

  1. Exit VS.NET, restart VS.NET and reopen project
  2. Change project from Debug Build to Release Build and visa-versa.
  3. Remove all Enums from classes and just use in the namespace
  4. Ensure all DLL projects have  ‘CopyLocal’ set to true AND references to these DLL’s be a Project Reference and not simple a DLL reference.

I followed all of the guidance of the experiences I saw in my Google search with #1 working every time.  The only problem with this solution was exiting and restarting VS.NET all the time.  In case you haven’t had the pleasure, it takes a long time to load.  Although this worked, it didn’t seem the greatest solution to me and was a poor way to fix a deeper problem.

Further sluething using Process Explorer from Sysinternals revealed Devenv.exe was holding my PDB file open.  A post to the MSDN .NET General Newsgroup let to some further clues.

As I pointed out, I am not the only one having this problem, and it seems Microsoft is well aware of these issues.  KnowledgeBase articles 313512 and 887818 show occurances of the bug and a hotfix that is available by request-only.  I don’t think this is the right approach to such an annoying problem and either does Frans Bouma who has a great post on his blog about this very problem and the lack of service pack for VS.NET 2003.

I called Microsoft to request this hotfix and the person I spoke with fromt he VS.NET 2003 C# Support Team told me I was the third person requesting this hotfix THIS MORNING.  So, why don’t we see a service pack before now? We have seen multiple hotfixes for Windows XP already and VS.NET 2003 has been in use just as long.  If I recall correctly we had six service packs for Visual Studio 6.

I have installed the hotfix and all seems to be working well with no problems reported.  I hope this helps others out there.


2 responses to “Visual Studio .NET 2003 C# Compile Error CS0042

  1. Thank you for your help. I have recently started to work in some softver company. I am
    totaly inexperience and error CS0042 has emerge from depths of hell to ruin my career at
    the beginning. Thank you again, and thank you in advance for solving another errors from

  2. Your very welcome. I am glad I could help. The idea behind my blog is to share experience, which is how so many problems are solved.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s