Could not load file or assembly Microsoft.Xaml.Behaviors

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:9

github_iconTop GitHub Comments

4reactions
Jebarsoncommented, Feb 3, 2021

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}"

3reactions
jerrudcommented, Dec 23, 2021

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:

        public MainWindow()
        {
            InitializeComponent();
            
            var _ = new Microsoft.Xaml.Behaviors.DefaultTriggerAttribute(typeof(Trigger), typeof(Microsoft.Xaml.Behaviors.TriggerBase), null);
        }
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found