web-dev-qa-db-fra.com

Pourquoi Windows 7 ne peut-il pas charger Assembly PresentationFramework.Aero2?

Je viens de terminer ma première application WPF que je développais sous Windows 8. Cela a bien fonctionné sur ma machine. Un de mes amis l’a également fait tourner dans Visual Studio sur sa machine Windows 8, et cela a fonctionné. J'installe le programme en utilisant click une fois sur ma machine, il s'installe correctement et s'exécute.

J'ai installé Windows 7 sur une boîte virtuelle et j'ai essayé de l'installer en cliquant une fois. Il récupérait .NET 4.5 et SQL Server Compact, le processus d'installation semblait sans faille. Lorsque Windows 7 a essayé d'exécuter l'application, rien d'utile ne s'est produit. J'ai installé Visual Studio dans virtualbox et j'ai pu obtenir cette trace de pile.

J'ai consulté le PresentationFramework.Aero2 sur Google et suis tombé sur 3 SO questions et une question MSDN. La question MSDN m'a donné une idée de ce que je pense que cela pourrait être. Si je vais dans C:\Windows\Microsoft.NET\Framework\4.0\WPF, il n'y a pas de fichier PresentationFramework.Aero2.dll, alors que sur Windows 8, il y en a ... donc je l'ai copié et collé dans le même emplacement que Windows 7 dans l'espoir pour atteindre quelque chose, mais rien n'en est sorti.

Voici la trace de pile:

System.Windows.Markup.XamlParseException was unhandled
  HResult=-2146233087
  Message='Add value to collection of type 'System.Collections.ObjectModel.ObservableCollection(System.Windows.Controls.DataGridColumn)' threw an exception.' Line number '35' and line position '71'.
  Source=PresentationFramework
  LineNumber=35
  LinePosition=71
  StackTrace:
       at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
       at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
       at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
       at System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc)
       at System.Windows.Application.LoadComponent(Uri resourceLocator, Boolean bSkipJournaledProperties)
       at System.Windows.Application.DoStartup()
       at System.Windows.Application.<.ctor>b__1(Object unused)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()
       at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.ProcessQueue()
       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.Run()
       at System.Windows.Application.RunDispatcher(Object ignore)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run(Window window)
       at System.Windows.Application.Run()
       at PremierAutoDataExtractor.App.Main()
  InnerException: System.IO.FileNotFoundException
       HResult=-2147024894
       Message=Could not load file or Assembly 'PresentationFramework.Aero2, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
       Source=mscorlib
       FileName=PresentationFramework.Aero2, PublicKeyToken=31bf3856ad364e35
       FusionLog=WRN: Assembly binding logging is turned OFF.
To enable Assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with Assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

       StackTrace:
            at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
            at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
            at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
            at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
            at System.Windows.Baml2006.Baml2006SchemaContext.ResolveAssembly(BamlAssembly bamlAssembly)
            at System.Windows.Baml2006.Baml2006SchemaContext.ResolveBamlTypeToType(BamlType bamlType)
            at System.Windows.Baml2006.Baml2006SchemaContext.ResolveBamlType(BamlType bamlType, Int16 typeId)
            at System.Windows.Baml2006.Baml2006SchemaContext.GetXamlType(Int16 typeId)
            at System.Windows.Baml2006.Baml2006Reader.Process_ElementStart()
            at System.Windows.Baml2006.Baml2006Reader.Process_OneBamlRecord()
            at System.Windows.Baml2006.Baml2006Reader.ReadObject(KeyRecord record)
            at System.Windows.ResourceDictionary.CreateObject(KeyRecord key)
            at System.Windows.ResourceDictionary.OnGettingValue(Object key, Object& value, Boolean& canCache)
            at System.Windows.ResourceDictionary.OnGettingValuePrivate(Object key, Object& value, Boolean& canCache)
            at System.Windows.ResourceDictionary.GetValueWithoutLock(Object key, Boolean& canCache)
            at System.Windows.ResourceDictionary.GetValue(Object key, Boolean& canCache)
            at System.Windows.DeferredResourceReference.GetValue(BaseValueSourceInternal valueSource)
            at System.Windows.DeferredAppResourceReference.GetValue(BaseValueSourceInternal valueSource)
            at System.Windows.DependencyObject.GetEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, RequestFlags requests)
            at System.Windows.DependencyObject.GetValueEntry(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, RequestFlags requests)
            at System.Windows.DependencyObject.GetValue(DependencyProperty dp)
            at System.Windows.Controls.DataGridHelper.GetCoercedTransferPropertyValue(DependencyObject baseObject, Object baseValue, DependencyProperty baseProperty, DependencyObject parentObject, DependencyProperty parentProperty, DependencyObject grandParentObject, DependencyProperty grandParentProperty)
            at System.Windows.Controls.DataGridColumn.OnCoerceHeaderStyle(DependencyObject d, Object baseValue)
            at System.Windows.DependencyObject.ProcessCoerceValue(DependencyProperty dp, PropertyMetadata metadata, EntryIndex& entryIndex, Int32& targetIndex, EffectiveValueEntry& newEntry, EffectiveValueEntry& oldEntry, Object& oldValue, Object baseValue, Object controlValue, CoerceValueCallback coerceValueCallback, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, Boolean skipBaseValueChecks)
            at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
            at System.Windows.DependencyObject.CoerceValue(DependencyProperty dp)
            at System.Windows.Controls.DataGridHelper.TransferProperty(DependencyObject d, DependencyProperty p)
            at System.Windows.Controls.DataGridColumn.SyncProperties()
            at System.Windows.Controls.DataGrid.UpdateColumnSizeConstraints(IList list)
            at System.Windows.Controls.DataGrid.OnColumnsChanged(Object sender, NotifyCollectionChangedEventArgs e)
            at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
            at System.Windows.Controls.DataGridColumnCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
            at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
            at System.Windows.Controls.DataGridColumnCollection.InsertItem(Int32 index, DataGridColumn item)
            at System.Collections.ObjectModel.Collection`1.Add(T item)
            at System.Collections.ObjectModel.Collection`1.System.Collections.IList.Add(Object value)
            at System.Xaml.Schema.XamlTypeInvoker.AddToCollection(Object instance, Object item)
            at MS.Internal.Xaml.Runtime.ClrObjectRuntime.Add(Object collection, XamlType collectionType, Object value, XamlType valueXamlType)
       InnerException: 
25
Robert

J'ai rencontré un problème similaire. Contexte: développement de l'application WPF sous Windows 8 à l'aide de Visual Studio 2012, Blend for 2012, .NET 4.5. APP.XAML a référencé PresentationFramework.Aero2 pour les thèmes. Distribution de l'application à l'aide de ClickOnce. 

Sous Windows 8, pas de problèmes. Sous Windows XP/Vista/7, l'application se bloquait en cours d'exécution (sur la première sous-page faisant référence à Aero2) avec l'exception "Impossible de charger l'assemblage" susmentionnée enregistrée.

Tentatives de résolution des problèmes: Indicateur Aero2 pour copier local dans le projet (n'a pas aidé), tentative d'inclusion dans le programme d'installation ClickOnce (n'apparaît pas dans la liste des assemblys disponibles), copie dans le dossier WPF sur l'ordinateur Windows7 cible sous c:\windows\Microsoft.net\framework\v4.xx\wpf (n'a pas aidé).

Résolution:

Remplacez la référence dans le projet de PresentationFramework.Aero2 à PresentationFramework.Aero, puis modifiez les références XAML afin qu'elles correspondent. Pourrait facilement pousser vers des machines non-Windows 8 et le faire fonctionner. Le développement fonctionne correctement. La seule différence constatée était l'apparence par défaut des barres de progression était brillant/3d. 

36
Paul Vilevac

Sur une machine de développement, il existe deux versions des assemblys d'infrastructure de présentation. Visual Studio fait référence à la version "métadonnées uniquement". Lorsque vous déployez l'assembly du dossier C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF, cela devrait fonctionner (voir Problème avec Assembly PresentationFramework.Aero2 )

0
mbihler