Alright. I got to the cause of the issue. I have no idea why, but the csproj file of the failing project had the following line:
Code: <AlwaysCompileMarkupFilesInSeparateDomain>false</AlwaysCompileMarkupFilesInSeparateDomain>
Frankly I have no idea why this was there and when it appeared, but after setting it to "true" (or completely removing it) the project started building without any problems. So... I guess my issue is resolved now.
UPDATE:
Just in case - found a thread about this flag here:
link. There is an important point there in the comments:
Quote:Blend 3 likes to default this to False as well...
Our project was also created in Blend 3 at some point, so I guess that this is where that flag came from. At the moment we are using Blend 4 and it does not set this flag in WPF/WPF lib projects by default (just checked).