I'm using VS2008 SP1 with the WPFToolKit v3.5.50211.1.
I have nested WPF UserControls in a Class Library project as follows:
MainWpfUserControl
- Contains an instance of
NestedUserControl
- Which contains an instance of a
DataGrid
from the WPF Toolkit.
The same Class Library project contains a WinForms UserControl with an ElementHost that hosts MainWpfUserControl
.
I've been getting strange errors when opening the WinForms UserControl in the designer. After a bit of digging around (catching and logging the exception thrown in the NestedUserControl
constructor), it seems that an exception is thrown as follows:
[A]Microsoft.Windows.Controls.DataGrid cannot be cast to [B]Microsoft.Windows.Controls.DataGrid. Type A originates from 'WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'LoadFrom' at location 'C:\Program Files\WPF Toolkit\v3.5.50211.1\WPFToolkit.dll'. Type B originates from 'WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'LoadNeither' at location 'C:\Documents and Settings\...\Local Settings\Application Data\Microsoft\VisualStudio\9.0\ProjectAssemblies\zfh65-u101\WPFToolkit.dll'
Has anyone experienced anything similar?
UPDATE
I seem to have successfully worked around the problem by putting WPFToolkit.dll in the GAC. But that's undesirable for other reasons (e.g. CopyLocal now defaults to false). So it seems the problem is related to Load Context. Is there any way to control this?