MaterialDesignInXamlToolkit: Could not load file or assembly 'MaterialDesignColors, Culture=neutral' or one of its dependencies
Hi am getting the following error when running my class library project.
“Could not load file or assembly ‘MaterialDesignColors, Culture=neutral’ or one of its dependencies. The system cannot find the file specified.”:“MaterialDesignColors, Culture=neutral”} System.Exception {System.IO.FileNotFoundException
I tried the below link forthe issue Could not load file or assembly 'MaterialDesignThemes.Wpf and the issue got fixed by adding the piece of code suggested as below .
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
ShadowAssist.SetShadowDepth(this, ShadowDepth.Depth0);
}
}
Is there any fix like above available for `MaterialDesignColors.dll ?
Note : All the dlls exists in same folder.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 6
- Comments: 39 (12 by maintainers)
For folks still encountering this issue: this post by Carlos Anderson explains what’s going on:
And provides a solution similar to what @z3ke1r suggests:
This solved it for me.
Hi, I encountered the same issue while attempting to load an application. I built upon @hedinjke’s good work by removing unnecessary calls to the
Assembly.LoadFrom()
method. I noticed that your suggestion would lead to many unnecessary calls - in my case, the same assembly would be loaded 16 times or so.Instead of using a
foreach
structure to iterate over the list of assemblies returned by:I return a list of strings and use LINQ expressions to compare between the assemblies already loaded, and the ones required by the
AppDomain.CurrentDomain.AssemblyResolve
event.return Assembly.LoadFrom(assemblyToLoad);
AssemblyLoader.cs
EnumerateFiles.cs
Finally found solution.
May be this gonna help someone. Here is it:
Usage example:
For anyone using this library in a Visual Studio extension, you have to do two things:
[ProvideBindingPath]
attribute to extension’sPackage
orAsyncPackage
file. This tells your XAML files to look at all the project’s references. See here for more details.@Arshad8464 @Keboo Solving it was pretty simple. Just Install MaterialDesignColors over NuGet as well
@Keboo Yes, I have isolated further to the pure WPF version. In this stage, it should reproduce the issue. In App.xaml I have left lines to comment out. If you do so comobox is working. Thanks for having a look. https://github.com/DesignboticTeam/MaterialDesignBug
Since it’s a reference error, i checked to see what could be a possible solution.
All i did was:
Right click your project Select Add --> Reference
In the menu Assemblies make sure Accessibility is activated.
That’s it, everything is working.
@Keboo i apologise for my late response. My second post was only one of many quick&dirty ways i tried in order to solve the problem, i should have posted the code that covers loading MatreialDesignColors as well (yet the error message would have been the same). What solved my problem was completely abendoning the code snipped from my second post and doing what @Arshad8464 and @z3ke1r did. I didn’t originally understand that this approach would solve the problem, because i was trying to follow MVVM pattern and keep code behind clean. Therefore it didn’t make any sense to me that they were suggesting to put bullshit code in the file that i was trying to keep empty. But hey, it works now! 😃
I had the same error. I used the shadow assist code above for the ‘MD Themes’ and used the code below to get the ‘Colors’.
var hue = new Hue("Dummy", Colors.AliceBlue, Colors.AntiqueWhite);