I came across a problem last week, I developed a custom user control for someone, this control use a lot of references. The guy send me an email with an error that say that the user control doesn’t find an assembly reference?
The way that we structure our folders are :
The project assembly reference the main assembly of the custom user control, if we compile we normally obtain an output folder which contains all of the 4 assemblies into this picture. But this is not the case, the assembly in red is not copied into the output folder. The reason is because we only use the assembly in red in xaml and not directly in C# code. There is a bug into the Xaml compiler which doesn’t add the reference correctly. So a solution is to add one line of code into the project assembly which construct one instance of any class from the referenced assembly 2 and the classic C# compiler will do the correct job.
I compile, the output folder contains effectively the WpfControlLibrary1, it is VS2008 which take the assembly because it is a project reference. Simply create a new project and reference the XamlDemo assembly and in this case, it will not work. We can see it with reflector:
And now the WpfControlLibrary1 is there, so pay attention to that because it can create deployment problem.