I have a problem that has puzzled me for some time now. On a WPF/.NET 3.5 product I have released, about 1 out of 100 installs will not be able to run the software at all due to the following error:
System.Windows.Markup.XamlParseException: Failed object initialization (ISupportInitialize.EndInit). The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Error at object 'System.Windows.Controls.MenuItem' in markup file 'mainwindow.xaml'.
This is puzzling for three reasons:
This only happens on about 1 to 2 percent of installs.
There is nothing unusual as far as I can tell about the .NET installations or OS on these systems.
This is happening with a default framework reference (System.Windows.Controls.MenuItem)
Can anyone think of possible causes for this?
EDIT: After following the tip from "500", I was able to run the Fusion log viewer on the customer machine. On the development machine and all other test machines, there are successful binding attempts on "PresentationFramework" and "PresentationFramework.Aero", which are expected. On the client machine, there is an additional binding attempt that fails (Irrelevant lines removed):
*** Assembly Binder Log Entry (2/3/2013 @ 1:18:44 PM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = PresentationFramework.Dawn TOP, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: PresentationFramework.Dawn TOP, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/My App/PresentationFramework.Dawn TOP.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/My App/PresentationFramework.Dawn TOP/PresentationFramework.Dawn TOP.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/My App/PresentationFramework.Dawn TOP.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/My App/PresentationFramework.Dawn TOP/PresentationFramework.Dawn TOP.EXE.
LOG: All probing URLs attempted and failed.
A Google search for "PresentationFramework.Dawn" returns no results and I cannot locate any reference to this file. Any explanation or additional tests that can be done?
EDIT 2: It turns out that the customer had installed an unofficial Windows 7 Aero theme called "Dusk". For some reason, PresentationFramework decided to make a call to PresentationFramework.Dusk instead of PresentationFramework.Aero (a reference that I explicitly included in the project). I'm assuming that the error is the result of a bad installation of the 3rd party theme since Dusk cannot be found in the GAC, but can you shed any light on how I might stop the reference from being attempted and force all GUI elements to use PresentationFramework.Aero?
An assembly manifest contains all the metadata needed to specify the assembly's version requirements and security identity, and all metadata needed to define the scope of the assembly and resolve references to resources and classes.
Reference assemblies are usually distributed with the Software Development Kit (SDK) of a particular platform or library. Using a reference assembly enables developers to build programs that target a specific library version without having the full implementation assembly for that version.
A manifest is some XML (typically embedded into . dll and .exe files) which can (among other things) specify the exact version of the Microsoft Visual C++ runtime (MSVCRT) that an application requires.
On those machines where it fails, run the Assembly Binding Log Viewer to gain a better understanding of why it's going off the rails.
In your application you can specify which Theme you want to use to force another theme than the system theme.
This code needs to be added to your ApplicationStartUp event
void App_Startup(object sender, StartupEventArgs e) {
// other startup code
Uri uri = new Uri(“PresentationFramework.Aero;V3.0.0.0;31bf3856ad364e35;component\\themes/aero.normalcolor.xaml”, UriKind.Relative);
Resources.MergedDictionaries.Add(Application.LoadComponent(uri) as ResourceDictionary);
}
You can also define your Theme in XAML:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source=“/PresentationFramework.Aero;V3.0.0.0;31bf3856ad364e35;component\themes/aero.normalcolor.xaml“ />
</ResourceDictionary.MergedDictionaries>
<!– other resources go here –>
</ResourceDictionary>
</Application.Resources>
This setting defines that you want to use the Aero theme. (Maybe you need to change the version and the public key token you want to use).
Further information can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With