MSBuild fails to compile WPF with: error MC2000: Unkown build error '…' does not have an implementation

My initial solution in this post was WRONG, it just changed the compile order of our build which made the error occur later after other issues were resolved. I’ve updated the post accordingly. I’m sorry if anyone had to read this post twice.

We have been struggling with a build error lately, where the compilation works perfectly in Visual Studio, and in our case it also works in some MSBuild builds but not in this specific build. By that I mean that two builds are compiling the same code, with the same dependencies and compilation flags, yet one fails and the other doesn’t.

The error message given is:

D:\Invoicing\UQList.xaml(55,167): error MC2000: Unknown build error, 'Method 'add_PropertyChanged' in type 'UsageQuantityPresenter' from assembly 'ServiceManagementApplication' does not have an implementation. Line 55 Position 167.'

If we look at the buildlog.txt produced by MSBuild in the failing build, we can find something similar to this:

 Input file 'D:\Invoicing\UQList.xaml' is resolved to new relative path 'Invoicing\UQList.xaml' at directory 'D:\'. D:\Invoicing\UQList.xaml(55,167): error MC2000: Unknown build error, 'Method 'add_PropertyChanged' in type 'UsageQuantityPresenter' from assembly 'ServiceManagementApplication' does not have an implementation. Line 55 Position 167.' Input file 'D:\Trait\TraitsView.xaml' is resolved to new relative path 'Trait\TraitsView.xaml' at directory 'D:\'.
 ...
 Generated BAML file: 'D:\obj\Release\Themes\luna.normalcolor.baml'. Generated BAML file: 'D:\obj\Release\Trait\TraitsView.baml'. Markup compilation is done. Done executing task "MarkupCompilePass2" -- FAILED. Done building target "MarkupCompilePass2" in project "ServiceMangementApplication.csproj" -- FAILED.

In the XAML we are depending on the UsageQuantityPresenter to implement INotifyPropertyChanged, which it does. However it also implements other interfaces and does inheritance of a base-class.

This is what it looked for for us:

/// <summary>
/// UsageQuantityPresenter
/// </summary>
public class UsageQuantityPresenter : EntityViewPresenterBase, IUsageQuantity { ...

The EntityViewPresenterBase (I hate that class name by the way) implements INotifyPropertyChanged.

The solution was found in the following forum tread: http://social.msdn.microsoft.com/Forums/en/wpf/thread/00907c94-c6b2-4bf1-98f9-113c5c4392d8

It states that you should add:

<AlwaysCompileMarkupFilesInSeparateDomain>true</AlwaysCompileMarkupFilesInSeparateDomain>

to the .csproj file with the XAML files. Doing this makes MSBuild happy again.