Melursus
Melursus

Reputation: 10578

WPF: Assembly resolver

I've got the following XAML definition:

xmlns:controls="clr-namespace:MyControls;assembly=MyProduct.MyControls"

Let say my product have the dll MyProduct.MyControls loaded 2 times (2 differents versions). For example version 1.0 and version 2.0.

Is there a way to explicitly resolve the assembly "MyProduct.MyControls" for the XAML?

Upvotes: 2

Views: 785

Answers (3)

mathieu
mathieu

Reputation: 31202

According to MSDN ( http://msdn.microsoft.com/en-us/library/ms747086.aspx#Mapping_To_Custom_Classes_and_Assemblies ), you can specify the full name of the assembly, using the AssemblyName syntax :

xmlns:controls="clr-namespace:MyControls;assembly=MyProduct.MyControls, Version=1.0.0.0, Culture=en, PublicKeyToken=xyz"

Upvotes: 2

DHN
DHN

Reputation: 4865

Well according to this you won't be successful.

I just get the confirmation that XAML parser will deliberately prevent you to use multiple version of same assemblies, which means that if the old version of assembly already exists, WPF will try use that assembly even if your XAML document is trying to reference a new version.

Upvotes: 0

ywm
ywm

Reputation: 1127

From reading this link on the MSDN site, It looks like you use the AssemblyName to load the assembly, so it might be the case where you compile your different versions with MyProduct.MyControlsV1 as the name in the AssemblyInfo.cs for example.

So the path would become

xmlns:controls="clr-namespace:MyControls;assembly=MyProduct.MyControlsV1"
xmlns:controls="clr-namespace:MyControls;assembly=MyProduct.MyControlsV2"

Upvotes: -1

Related Questions