Home > database >  Why have to add to GAC. DLL already given in exe folder
Why have to add to GAC. DLL already given in exe folder

Time:01-01

I wrote an shell extension in c#. App shows WPF Dialogs and I use Xaml.Behaviors When I run the App. All other DLL are found. But App throw an exception for missing Microsoft.Xaml.Behaviors.dll (but is actually in same folder)

so I run: gacutil.exe /i ...\bin\Debug\Microsoft.Xaml.Behaviors.dll This fix my issue.

My quesion is why other dlls are found and not xmal_behaviors?

Is it possible to skip the GAC step?

CodePudding user response:

Try adding a reference to the DLL in your project and set the "Copy Local" property to true. This will cause the DLL to be copied to the output directory of your application when it is built, and loaded from that location at runtime.

CodePudding user response:

Behaviors is now offered as a nuget package.

The way you're intended to use them is to Manage Nuget Packages, find Microsoft.Xaml.Behaviors.Wpf and "install" that.

eg

enter image description here

You then need a xmlns in your view.

         xmlns:i="http://schemas.microsoft.com/xaml/behaviors"

And an example usage:

                <TextBox Text="{Binding NettPer, StringFormat='{}{0:C}'}" Grid.Column="1">
                    <i:Interaction.Behaviors>
                        <b:SelectAllTextBoxBehavior/>
                    </i:Interaction.Behaviors>

The above is from a real solution, which is compiled to target .net 6 and works fine without that behaviors dll in the machine GAC.

  • Related