In our team we have a database project in visual Studio 2008 which is under source control by Team Foundation Server. Every two weeks or so, after one co-worker checks in, the project file won't load on the other developers machines. The error message is:
The project file could not be loaded. Data at the root level is invalid. Line 1, position 1.
When I look at the project file in Notepad++, the file looks like this:
��<NUL?NULxNULmNULlNUL NULvNULeNULrNULsNULiNULoNULnNUL
...
and so on (you can see <?xml version
in this)
whereas an normal project file looks like:
<?xml version="1.0" encoding="utf-16"?>
...
So probably something is wrong with the encoding of the file. This is a problem for us because it turns out to be impossible to get the file encoding correct again. The 'solution' is to throw away the project file an get the last know working version from source control.
According to the file, the encoding should be UTF-16. According to Notepad++, the corrupted file is actually UTF-8.
My questions are:
- Why is Visual Studio messing up the encoding of the project file, apparently at random times and at random machines?
- What should we do to prevent this?
- When it has happened, is there a possibility to restore the current file in the correct encoding instead of pulling an older version from source control?
As a last note: the problem is with one single project file, all other project files don't expose this problem.
UPDATE: Thanks to Jon Skeet's suggestion I have the answer to question number three. When I replace the first nine bytes EF BB BF EF BF BD EF BF BD by the two bytes FF FE, the project file will load again.
This leaves still the question why Visual Studio corrupts the file.