Wednesday, March 25, 2009

Solving compile errors: CS0006, CS0009 in Visual Studio 2008

Recently, when I was trying to run any web application project, I was getting the following error message:

CS0006: Metadata file 'C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll' could not be found

So, I searched the net for solution, and this is how I was able to solve it:

First, check whether "System.EnterpriseServices.dll" file actually exists at that folder or not. You cannot navigate to the GAC_32 folder using windows explorer. You have to use command line to go there. From start menu, select 'Run' > type 'cmd' press enter. then directly go there:

cd C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a

press enter. then use dir /p command to see all files in it and search for the "System.EnterpriseServices.dll" file if you cannot find it there, then again go to this location:

cd C:\Windows\Microsoft.NET\Framework\v2.0.50727

press enter. From here you have to copy the file to the desired location. Use this command:

copy System.EnterpriseServices.dll C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a

Now try to run that web project from visual studio, and it should work. If it doesnt work, and gives you another error: CS0009 compile error, then you have to copy all the files to that folder. First navigate to that source folder:

cd C:\Windows\Microsoft.NET\Framework\v2.0.50727

press enter. Then use this command to copy all DLLs:

copy *.dll C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a

You dont need to overwrite any file that already exists at the destination folder. This should solve CS0009 error.

22 comments:

Unknown said...

Awesome!

Arun Joel said...

thanks.

Anonymous said...

God Send, I have been fighting this for 3 HOURS!

You Rock

Unknown said...

You saved me a lot of time! Thank you!

cosmicice said...

Thanks mates... I am glad that I was able to help. :)

Anonymous said...

BLESS YOU SIR! I can't believe how long I searched for this and how stupid easy it is to fix. Everyone else is all re-intallling windows and nonsense. I was using VS2010 having upgraded a VS2008 web services project on my home box. I didn't even have .Net2.0 pre sp2. Oy. THANKS!

Jitin said...

Worked like a charm. Thanks so much...

Kevin T Parker said...

what does one do in a hosted environment? I have spend an hour on the phone with them and cant get any resolution.

flexy said...

Worked grt for me,took hardly 2 mins:) thanks mate

Unknown said...

I had the problem mentioned. And it was solved following the steps. Thanks for the post!

amatoryazilim said...

thanks my friend

hari said...

very very thanks....

hari said...

Very very thanks......

Amandeep Singh said...

Excellent... Buddy THANKS A LOT...

Dean Willson said...

I ran into this error deploying an application created in VS 2010 (on a different workstation) to a Server 2003 IIS 6 staging server that had previously hosted .Net 2.0 and 3.5 web apps. I'm not sure why the error occured this time, but your solution worked exactly as described. I had to copy all dll's. Thanks!

Luke said...

Thanks very much for this, didnt think to check see where the command line can go and windows explorer cant.

Shri said...

thanxxxx yaar

miscellaneousInfo said...

Thanx! this is just great!!

Anonymous said...

Thanks a lot, this fixed my issue!
YOU DA MAN!

Anonymous said...

Thanks a lot, this fixed my issue!
YOU DA MAN!

Dave Brown said...

Worked As Advertised!
Great work

cosmicice said...

@Everyone: Thanks... I m glad I could help.
@Kevin T Parker: For hosted environments, I guess, you need to republish the website from a PC where you have visual studio (after fixing the dll copying), and then host it again.