Could not load file or assembly Microsoft.Xaml.Behaviors
See original GitHub issueDescribe the bug Using behaviors in my xaml brings compilation error message.
To Reproduce
<Window x:Class="Aveva.SplashScreen.Sample.View.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
>
<b:Interaction.Triggers>
<b:EventTrigger EventName="MouseDown" >
<b:InvokeCommandAction
Command="{Binding MouseDownCommand}"
CommandParameter="{Binding Mode=OneWay, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window }}" />
</b:EventTrigger>
</b:Interaction.Triggers>
Error
System.Windows.Markup.XamlParseException: 'Could not load file or assembly 'Microsoft.Xaml.Behaviors, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.'
Expected behavior To work out of the box, without having to reference library in code behind. Because it works fine if I reference anything:
public MainWindow()
{
InitializeComponent();
var _ = new Microsoft.Xaml.Behaviors.DefaultTriggerAttribute(typeof(Trigger), typeof(Microsoft.Xaml.Behaviors.TriggerBase), null);
}
Desktop (please complete the following information):
- Version with bug: 1.1.31
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:9
Top Results From Across the Web
Could not load file or assembly 'System.Windows.Interactivity'
Go to the output Path director using windows explorer. Then see whether the 'System.Windows.Interactivity.dll' exist in that folder. It might ...
Read more >WPF Behaviors no longer working with newest NuGets.
Hi. The app used to work fine, but a few weeks ago we updated hundreds of NuGet packages. We recently discovered that any...
Read more >WPF .NET application breaks with error Could not load file ...
Hello, I have a C# WPF .NET application that uses a 3rd party SDK called PaymentSDK.dll which I include and reference inside the...
Read more >How to resolve “Could not load file or assembly … or one of its ...
GAC: Assembly is checked in Global Assembly Cache, it must be strongly named. Code base or Probing: First checks in location in <codeBase>...
Read more >XamlParseException - Could not load file or assembly
I have a WPF Application, WpfApplication1, and I'm referencing a WPF User Control ... XamlParseException - Could not load file or assembly.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This a repro for me. It happens when the Page is in a class library. The easiest workaround is to name behavior command in the xaml.
<Behaviors:InvokeCommandAction x:Name="SelectionCommand" Command="{Binding SelectedItemsChangedCommand}"I have the OPs same problem using version 1.1.39. The view is simply a Window in a folder in a class library. The library is a plug-in for another application. Creating a new WPF application and loading in that app as a plugin to the host app does not have this exception.
I was able to use OPs work around and view now works: