TFS Error–Source File Could Not Be Opened (‘Unspecified error ‘)
Symptom
File has already been deleted (from source control and from the filesystem). Yet – the file shows up in the Visual Studio solution (with a yellow warning icon next to it). When one tries to compile, one sees the above error:
source file could not be opened ‘unspecified error ‘
What does not work
By now you’ve already tried all the usual suspects. Tried refreshing, closing (and re-opening VS), clean command etc. Nothing seems to work.
The Source of the Problem
Something in Visual Studio is obviously remembering a reference to the file path and name. An obvious suspect is the .csproj file for your project. If you look inside it, you will see a reference to the source file that is throwing the above error.
The Solution
Simply delete the entry from your .csproj file – and you should be good to go. Somehow, the .csproj did not remove the entry when you removed this file (perhaps because you first deleted it from the filesystem before deleting it from the solution). That’s it – if you run into this obscure ‘Source file could not be opened – Unspecified Error’, try editing your .csproj file and see if that fixes it.
Hi Anuj,
Thanks a lot for this post. I wish I would have read it yesterday and could have saved my time!
I had this error (Source File Could Not Be Opened (‘Unspecified error ‘)) and other 4 errors saying ‘metadata file could not be found’. Yesterday, I concentrated on those other 4 errors. Tried everything, but could not get rid of those. Today morning, I read your blog and decided to get rid of that 1 error (Source File Could Not Be Opened (‘Unspecified error ‘)) which I was having and surprisingly, I got rid of those other 4 errors as well.
Do you know the reason why this error and ‘metadata file could not be found’ can be related to each other?
Thanks!
-Vikram.
If this happened suddenly, it could also mean a change in antivirus policy(symantec). I updated the symantec policy and then tried it. It should take a while to update it. Also tried building without network cable attached. Finally it succeeded to build the project.
Hi Anuj,
Thanks a lot for this very useful post. My big problem got solved!