views:

330

answers:

2

I have a mixed Winform/WPF application which frequently throws the exception:

Could not load file or assembly <Full Assembly Name> or one of it's dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT 0x80131040) Error at object <Object Name> in markup file <file>.xaml

The WPF portion consists of a base custom control and multiple User Controls which inherit from that base. All of the WPF classes and templates are located within the same assembly.

This exception only started occuring after I strongly named all the assemblies in the application.

All of the assemblies used by the project are loaded in to a single visual studio solution.

Now for the confusing part. This exception only occurs part of the time. If I rebuild the entire solution sometimes it will be a good build and everything will work fine. Other times I'll rebuild the solution and it will be a bad build and the WPF sections will always throw this exception.

To fix it, I end up using the Clean Solution menu item and rebuilding multiple times until it gives me a "good" build.

It seems clear that the issue is the linker mismatching assembly versions from previous builds. However, I'm stumped why it would do this. The build order and project dependencies is set correctly.

+1  A: 

Yeah, I've seen this kind of thing before too. Not sure if it's an option for you, but could you try explicitly setting the version number of all signed assemblies rather than auto-incrementing it?

HTH, Kent

Kent Boogaart
I'll try that and let you know.
aef123
I've now done several dozen builds and none of them have had the issue I reported. It looks like your suggestion fixed it.Thanks for the help.
aef123
A: 

If you get the problem, please vote here link text

Matt