Ich habe eine WPF-Anwendung, die das MVVM Muster folgt. Wir haben die App vor kurzem unterschrieben und jetzt bekomme ich beim Start viele erste Ausnahmen. Ich habe das Problem auf die folgende verfolgt:System.IO.FileLoadException wenn Anmeldung erkennen
in einer beliebigen Ansicht, wenn ich einen anderen Namensraum mit der Anwendung verweisen, wenn die Ansicht initialisiert wird erhalte ich die Fehlermeldung:
"Could not load file or assembly 'MyApplication, Version=3.0.5917.24348, Culture=neutral, PublicKeyToken=xxxxxxxxxxxx' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"MyApplication, Version=3.0.5917.24348, Culture=neutral, PublicKeyToken=xxxxxxxxxxx"
Seine immer auf der Suche nach einer Version, die ist 1 hinter der Version, die ich tatsächlich ausgeführt werde.
Wenn ich die Verweise auf die anderen Namensräumen aus den Ansichten entfernen, wird die InitializeComponent()
nicht werfen den Fehler
Ausblick:
<UserControl x:Class="MyApplication.View.DiagnosticsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:convert="clr-namespace:MyApplication.Converters" <!--Causes error-->
xmlns:behave="clr-namespace:MyApplication.Behaviors" <!--Causes error-->
xmlns:controls="clr-namespace:MyApplication.UserControls" <!--Causes error-->
Wenn ich diese Referenzen, entfernen und meine Konverter und Verhaltensweisen bewegen in eine andere DLL und dann verweisen sie über die DLL gibt es kein Problem. Die Fehler gehen weg. Auch wenn ich die Anwendung nicht unterzeichne, bekomme ich die Fehler nicht. Ich möchte diese Dinge nicht wirklich in einer anderen DLL referenzieren müssen, es scheint, als sollte das gut funktionieren. Es verbringt auch ungefähr 30 Sekunden, alle diese Fehler zu werfen, da alle Ansichten erstellt werden, also nehme ich einen Schlag auf Leistung. Ich verstehe nicht, warum die Anwendung versucht, sich selbst zu laden, und warum sie versucht, eine ältere Version von sich selbst zu laden. Egal wie oft ich baue, der Fehler ist immer 1 Version dahinter.
Fusion Log:
*** Assembly Binder Log Entry (3/17/2016 @ 10:30:11 AM) ***
The operation failed.
Bind result: hr = 0x80131040. No description available.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\tfs\Development\dev-feature\src\MyApplication\bin\Debug\MyApplication.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = MyApplication, Version=3.0.5920.15594, Culture=neutral, PublicKeyToken=xxxxxxxxxxxx
(Fully-specified)
LOG: Appbase = file:///C:/tfs/Development/dev-feature/src/MyApplication/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MyApplication.exe
Calling assembly : PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\tfs\Development\dev-feature\src\MyApplication\bin\Debug\MyApplication.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: MyApplication, Version=3.0.5920.15594, Culture=neutral, PublicKeyToken=7b0591cb18d2a932
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/tfs/Development/dev-feature/src/MyApplication/bin/Debug/MyApplication.DLL.
LOG: Attempting download of new URL file:///C:/tfs/Development/dev-feature/src/MyApplication/bin/Debug/MyApplication/MyApplication.DLL.
LOG: Attempting download of new URL file:///C:/tfs/Development/dev-feature/src/MyApplication/bin/Debug/bin/MyApplication.DLL.
LOG: Attempting download of new URL file:///C:/tfs/Development/dev-feature/src/MyApplication/bin/Debug/bin/MyApplication/MyApplication.DLL.
LOG: Attempting download of new URL file:///C:/tfs/Development/dev-feature/src/MyApplication/bin/Debug/MyApplication.EXE.
LOG: Assembly download was successful. Attempting setup of file: C:\tfs\Development\dev-feature\src\MyApplication\bin\Debug\MyApplication.exe
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: MyApplication, Version=3.0.5920.15596, Culture=neutral, PublicKeyToken=7b0591cb18d2a932
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: The assembly reference did not match the assembly definition found.
ERR: Run-from-source setup phase failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
ich gefunden, wenn ich eine harte Version in den Anwendungseigenschaften wie 3.0.0.0 gesetzt ich nicht den Fehler. Allerdings, wenn ich die Version 3.0 habe. * Ich bekomme die Fehler. – user1336827
Wie signierst du es? – FriendlyGuy
Ich überprüfe "Signiere die Assembly" unter der Signierung Registerkarte in Projekt -> Eigenschaften, dann wählen Sie unsere Schlüsseldatei. – user1336827