Assembly reference problem with XAML in .Net 3.5

Labels:

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 :

image

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.

Sample

I create a sample solution with 2 projects:
image

The XamlDemo project reference the WpfControlLibrary1. In my Window1.xaml I use the control:
image

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:
image

We can see that the XamlDemo.exe doesn’t contain any reference to the WpfControlLibrary1.
Now we add a simple line of code:
image

I use one class of the WpfControlLibrary1 and now in reflector:
image

And now the WpfControlLibrary1 is there, so pay attention to that because it can create deployment problem.







IERssNotificator version 1.2.0.0

Yes, the project is yet alive. This new version adds 3 corrections and 4 improvements :

New stuff added:
................

  • logs error
  • new configuration option to disable the reshow of the notification window at regular interval when posts are unread
    image
  • notification icon change when there are unread posts
    image
  • some layout stuffs improvements like font size on the notification window, added scroll bar if too many unread posts

Bugs corrected:
...............

  • when new post detected the notification window is displayed but doesn't hide after the defined time
  • when click on the the mark feed as read button, it throw a null reference exception
  • if rename/remove/add feed into IE while in the configuration window, the list of feeds are not refreshed.

Download IERssNotificator V1.2.0.0