Could not load assembly, Exception from HRESULT: 0x80131040 - wpf

Exception:
Could not load file or assembly 'WPFVisifire.Charts, Version=4.1.0.0, Culture=neutral, PublicKeyToken=99d724542e4db593' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
We are working with our stock exchange charting application using Visifire. We have two app versions. Online Silverlight version and desktop WPF version. I already created Silverlight application and its working well. Same code I copied in WPF application but WPF chart application throws exception.
I’m very new to dot net development. Please help.

Are you using Windows7 OS?
I suggest you to follow the steps below.
Remove reference of WPFVisifire.Charts.dll and WPFToolkit.dll (if
used) from your project.
Clean your project.
Close the application.
Right click no WPFVisifire.Charts.dll and WPFToolkit.dll(if used) then click on properties.
Go to General Tab.
Click on Unblock button.
Now open your project in Visual Studio.
Add new reference to unblocked WPFVisifire.Charts.dll and
WPFToolkit.dll(if used).
Compile your project and run.

Related

Including UWP project in WPF project raises runtime errors

Project I work on need to show UWP control from UWP library inside of WPF window.
Here is the document page on which I had based my work (check section for adding custom UWP control):
https://learn.microsoft.com/en-us/windows/communitytoolkit/controls/wpf-winforms/windowsxamlhost#add-a-custom-uwp-control
Had setup WPF window and it shows standard UWP controls (like button) at the runtime just fine. However, when I include UWP project, WPF window throws exception at start (at the moment of context initialization of EF).
Could not load file or assembly 'Windows.Foundation.UniversalApiContract, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
Sqlite version I'm using is 1.0.88.0 and EF is 5. But it doesn't make any sense that it clashes with these libraries?
Ffixed an issue on startup by updating SQLite package to 1.0.111.0 and EF to version 6.2.0.
Including UWP project in WPF project raises runtime errors
Derive from official document, I create sample project. When build the project, it throw many errors that lost assembly. After add the Windows.winmd file every thing work well. You could try to add the Windows.winmd file where in the C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd to WPF app reference.
Detail steps
Right click project References -> Add References -> Browse(file type all file)-> select Windows.winmd
And this sample project that you could refer this.

Using Mahapps.Metro Flyouts in Elementhost

I'm writing a SolidWorks addin, where I can host WPF only within an Winforms Elementhost. Now I want to use a Flyout from Mahapps.Metro, which depens on being hosted in a MetroWindow. Is there any way I can use the Flyout from within a WPF Usercontrol? I'm using .NET 4.6.2, Mahapps.Metro 1.6 and SolidWorks 2018.
Looks like the Information I found here and here is obsolete. I just installed the NuGet Packages Mahapps.Metro and Mahapps.Metro.Iconpacks and everything is working as expected.
If someone is trying to do it in a SolidWorks Addin too, make sure to manually load a new version of System.Windows.Interactivity, because Solid is loading an old version from the application base directory, which is not compatible with Mahapps.Metro!
Be very careful when you are working with .NET add-ins for solidworks. If your application uses some third-party UI lib, you need to copy those referenced assemblies to the host application (sldworks.exe) directory. For some reason, the domain application is that of hosting exe and not the dll. CLR will look for references in the sldworks.exe's directory and it doesn't find, the application throw some nasty exception that will crash your SOLIDWORKS.

Could not load file or assembly 'Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime'

After installing vs2012 and updating my vs2010 WPF project I get the following error in WPF designer:
Could not load file or assembly 'Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
This happens for every xaml page in the project.
<dx:DXWindow.DataContext>
<vm:MyViewModel/>
</dx:DXWindow.DataContext>
VS marks vm:MyViewModel as the problem line. If I comment it out the designer windows shows a blank page. This same projects works fine in VS2010. The target framework is set to 4 in both versions of visual studio.
This is a bug in Entity Framework (EF5) when used with Visual Studio 2012 or in a project that references a winmd assembly.
EF tries to load all referenced assemblies to check if they contain pre-compiled views. During this process EF5 fails when it tries to load a winmd assembly. Trying to load winmd assemblies with Assembly.Load causes a System.IO.FileLoadException which is not handled in EF5.
NOTE: Although your application might not have a reference to any .winmd assembly, VS2012 WPF Designer's host process (xdesproc.exe) has a reference to the Windows.winmd assembly. This explains why the projects work fine in VS2010 and during runtime. You can use .NET Reflector to confirm this.
This issue has been fixed in EF6.
A bug was filed for this http://entityframework.codeplex.com/workitem/609
and fixed in changeset 50c1e5a2c46d http://entityframework.codeplex.com/SourceControl/changeset/50c1e5a2c46d

unblocking Ribbon WPF assembly for use in VS2010

I'm trying to open the sample Solution for the Microsoft Ribbon for WPF, but I get this error about being unable to load metadata. The solution on that site, and the one linked in the error, is How to: Use an Assembly from the Web in Visual Studio. However, I don't see any 'Unblock' option when I check the Properties dialog for RibbonControlsLibrary.dll in C:\Program Files (x86)\Microsoft Ribbon for WPF\v3.5.40729.1. This may be because when I downloaded the Ribbon stuff, it wasn't the library directly, but rather an installer for the library. How can I get rid of this error so I can actually see the design view of the sample XAML files for the Ribbon WPF?
Here is the full error message:
Unable to load the metadata for assembly 'RibbonWindowSample'. This assembly may have been downloaded from the web. See http://go.microsoft.com/fwlink/?LinkId=179545. The following error was encountered during load: Could not load file or assembly 'RibbonWindowSample' or one of its dependencies. The system cannot find the file specified.
According to the error message, it's not RibbonControlsLibrary.dll that's at fault, it's RibbonWindowSample. Have you unbolocked the solution file and files that form the project? If RibbonWindowSample came pre-compiled, you may need to re-build the solution to generate compiled assemblies that don't have the "web mark" on them.
Did you download a zip file? You need to unblock the zip before unzipping it. Once it's unzipped you won't be able to unblock the individual files that were in it.
Here's what to look for at the bottom of the properties dialog.
I was seeing the metadata error before building the Solution--it shows up when I first load the Solution. I tried building it just now and it built fine, plus the design view shows the XAML window. I don't know why I see the metadata error when it first loads but it goes away upon building.

WPF VS2010 Upgrade - Now WPF designer throws exception when projects targets .NET framework 3.5

I recently upgraded a number of projects from VS2008 to VS2010. Now I'm having an issue at design time w/ the WPF designer in Visual Studio. It throws an exception for every XAML page I open in design mode. Exceptions also throw for new brand new XAML pages.
Projects currently target .NET 3.5. If I switch to target .NET 4.0, designer opens correctly.
Do note that projects build and run successfully.
The exception Details displayed in the WPF designer vary but scrolling to the bottom of the Details of all the exceptions do show something similar to:
The component 'MS.Internal.Interaction.AdornerFontResourceDictionary' does not have a resource identified by the URI '/Microsoft.Windows.Design.Interaction;component/ms/internal/interaction/adornerfontresourcedictionary.xaml'.
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at MS.Internal.Interaction.AdornerFontResourceDictionary.InitializeComponent()
at MS.Internal.Interaction.AdornerFontResourceDictionary..ctor()
at Microsoft.Windows.Design.Interaction.AdornerFonts.<.cctor>b__0()
at Microsoft.Windows.Design.Interaction.AdornerResources.EnsureResources(Boolean forceUpdate)
at Microsoft.Windows.Design.Interaction.AdornerResources.get_ThemeResources()
at MS.Internal.Themes.GenericTheme..ctor()
I'm guessing switching the framework targets is is causing the project to point to some older DLL. Any thoughts?
Following the upgrade, look through all the projects in the solution looking for references to any DLL named "Microsoft.Windows.Design*". Removing these references and recompiling will fix the issue.

Resources