This is a migrated thread and some comments may be shown as answers.

XamlParseException - Could not load file or assembly

2 Answers 1895 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rick Glos
Top achievements
Rank 1
Rick Glos asked on 13 Sep 2010, 10:24 PM
I have a WPF Application, WpfApplication1, and I'm referencing a WPF User Control library, WpfControlLibrary1.  In the WpfControlLibrary1, I'm referencing Telerik.Windows.Controls.  When I build and run (F5) the WPF Application, I get a XamlParseException - Could not load file or assembly...

I'm using a RadButton in a UserControl in the WpfControlLibrary1.

Checking the Debug\bin folder of the WpfApplication1, I can see the WpfControlLibrary1 was copied into the folder, but the Telerik.Windows.Controls.dll dependency from WpfControlLibrary1 as not copied.

If I add the reference to the WpfApplication1, it works but I shouldn't have to do that should I?  Shouldn't it figure out the dependencies and copy them from the child projects as necessary.

I've checked to make sure Copy Local = true.

2 Answers, 1 is accepted

Sort by
0
Accepted
Miro Miroslavov
Telerik team
answered on 16 Sep 2010, 01:20 PM
Hi Rick Glos,

 You are correct that Visual Studio automatically copies the referenced assemblies to the output directory, but only if it detects that something from that assembly reference chain is used. You can check the attached example project for that. However the problem here is that Visual Studio do Not detects the usages in Xaml, so it doesn't copy some of the assemblies to the output dir, thus the application crashes at run-time.
You can test this by removing the line that instantiate Class1 in the WPF app and instead create instance in xaml like <classlibrary1:Class1 />. The second way it won't copy the assemblies to the output dir.
Hope this help you.

All the best,
Miro Miroslavov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Rick Glos
Top achievements
Rank 1
answered on 16 Sep 2010, 06:54 PM
Yes thank you Miro.  I did not know this.

Another way I thought of to get this 'code-behind' hack to work was to add a Name element to the control so it would then create the stronger reference in the UserControl1.g.cs generated file.  That way I don't have to instantiate a class in the code-behind.  But really, either way works.

<telerik:RadButton x:Name="RadButtonTest" Content="Test"></telerik:RadButton>

Anyway, thanks again.
Tags
General Discussions
Asked by
Rick Glos
Top achievements
Rank 1
Answers by
Miro Miroslavov
Telerik team
Rick Glos
Top achievements
Rank 1
Share this question
or