IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C# Discussion :

[WPF] NullReferenceException sur un Mode=FindAncestor


Sujet :

C#

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Inscrit en
    Novembre 2010
    Messages
    105
    Détails du profil
    Informations forums :
    Inscription : Novembre 2010
    Messages : 105
    Par défaut [WPF] NullReferenceException sur un Mode=FindAncestor
    Bonjour,

    Je finalise une application en WPF et quand je la test sur un des environnements à ma disposition, j'ai des bugs là où sur les autres machines je n'en ai pas.

    C'est certainement dû à une dépendance logicielle non installée sur la machine...

    Lorsque je clique sur un bouton de mon interface, une liste d'objet devrait apparaitre, mais j'ai cette erreur à la place :

    L'exception System.NullReferenceException n'a pas été gérée
    Message=La référence d'objet n'est pas définie à une instance d'un objet.
    Source=xxxxxx
    StackTrace:
    à xxxxxx.View.SousMenu.System.Windows.Markup.IStyleConnector.Connect(Int32 connectionId, Object target) dans w:\1 - projet Visual\xxxxxx\xxxxxx\View\SousMenu.xaml:ligne 72
    à System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlReader templateReader, XamlObjectWriter currentWriter)
    à System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlObjectWriter objectWriter)
    à System.Windows.FrameworkTemplate.LoadOptimizedTemplateContent(DependencyObject container, IComponentConnector componentConnector, IStyleConnector styleConnector, List`1 affectedChildren, UncommonField`1 templatedNonFeChildrenField)
    à System.Windows.FrameworkTemplate.LoadContent(DependencyObject container, List`1 affectedChildren)
    à System.Windows.StyleHelper.ApplyTemplateContent(UncommonField`1 dataField, DependencyObject container, FrameworkElementFactory templateRoot, Int32 lastChildIndex, HybridDictionary childIndexFromChildID, FrameworkTemplate frameworkTemplate)
    à System.Windows.FrameworkTemplate.ApplyTemplateContent(UncommonField`1 templateDataField, FrameworkElement container)
    à System.Windows.FrameworkElement.ApplyTemplate()
    à System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    à System.Windows.UIElement.Measure(Size availableSize)
    à System.Windows.Controls.Border.MeasureOverride(Size constraint)
    à System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    à System.Windows.UIElement.Measure(Size availableSize)
    à System.Windows.Controls.Control.MeasureOverride(Size constraint)
    à System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    à System.Windows.UIElement.Measure(Size availableSize)
    à System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)
    à System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    à System.Windows.UIElement.Measure(Size availableSize)
    à MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
    à System.Windows.Controls.ItemsPresenter.MeasureOverride(Size constraint)
    à System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    à System.Windows.UIElement.Measure(Size availableSize)
    à MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
    à System.Windows.Controls.ScrollContentPresenter.MeasureOverride(Size constraint)
    à System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    à System.Windows.UIElement.Measure(Size availableSize)
    à System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
    à System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
    à System.Windows.Controls.Grid.MeasureOverride(Size constraint)
    à System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    à System.Windows.UIElement.Measure(Size availableSize)
    à System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
    à System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    à System.Windows.UIElement.Measure(Size availableSize)
    à System.Windows.Controls.Border.MeasureOverride(Size constraint)
    à System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    à System.Windows.UIElement.Measure(Size availableSize)
    à System.Windows.Controls.Control.MeasureOverride(Size constraint)
    à System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    à System.Windows.UIElement.Measure(Size availableSize)
    à System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
    à System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
    à System.Windows.Controls.Grid.MeasureOverride(Size constraint)
    à System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    à System.Windows.UIElement.Measure(Size availableSize)
    à MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
    à System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
    à System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    à System.Windows.UIElement.Measure(Size availableSize)
    à System.Windows.Controls.Border.MeasureOverride(Size constraint)
    à System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    à System.Windows.UIElement.Measure(Size availableSize)
    à System.Windows.Controls.Control.MeasureOverride(Size constraint)
    à System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    à System.Windows.UIElement.Measure(Size availableSize)
    à System.Windows.Controls.WrapPanel.MeasureOverride(Size constraint)
    à System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    à System.Windows.UIElement.Measure(Size availableSize)
    à System.Windows.ContextLayoutManager.UpdateLayout()
    à System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
    à System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
    à System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
    à System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
    à System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
    à System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
    à MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
    à System.Windows.Threading.DispatcherOperation.InvokeImpl()
    à System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
    à System.Threading.ExecutionContext.runTryCode(Object userData)
    à System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
    à System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
    à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    à System.Windows.Threading.DispatcherOperation.Invoke()
    à System.Windows.Threading.Dispatcher.ProcessQueue()
    à System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    à MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    à MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
    à System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
    à MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
    à System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
    à MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
    à MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
    à System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
    à System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
    à System.Windows.Threading.Dispatcher.Run()
    à System.Windows.Application.RunDispatcher(Object ignore)
    à System.Windows.Application.RunInternal(Window window)
    à System.Windows.Application.Run(Window window)
    à System.Windows.Application.Run()
    à _xxxxxx.App.Main() dans W:\1 - projet Visual\xxxxxx\xxxxxx\obj\Debug\Application.g.cs:ligne 0
    à System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
    à System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
    à System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
    à System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
    à System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
    à System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
    à System.Activator.CreateInstance(ActivationContext activationContext)
    à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
    à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
    à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    à System.Threading.ThreadHelper.ThreadStart()
    InnerException:
    à la ligne 72 du View\SousMenu.xaml se trouve ce code :
    Code xaml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    <Button Margin="2 1" Content="{Binding Value}" CommandParameter="{Binding Key}" PreviewMouseDown="Button_PreviewMouseDown" 
    Background="{Binding Key.Provenance, Converter={StaticResource ProvenanceToBrush}}" 
    Command="{Binding DataContext.OuvrirDossierSis, RelativeSource={RelativeSource AncestorType=StackPanel, Mode=FindAncestor}}"/>

    qui fait parti du template des objets qui devraient être affichés lors de l'appuie sur le premier bouton dont j'ai parlé.

    à première vu, au vu des messages de l'erreur, il me semble que cela vient de la méthode FindAncestor.

    Avez-vous des idées ?

  2. #2
    Membre confirmé
    Inscrit en
    Novembre 2010
    Messages
    105
    Détails du profil
    Informations forums :
    Inscription : Novembre 2010
    Messages : 105
    Par défaut
    Le problème était que j'avais installé la version 4 du Framework .Net et certaines fonctionnalités demandent la 4.5...


+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Agir sur le mode continu
    Par majong dans le forum IHM
    Réponses: 3
    Dernier message: 17/12/2007, 13h13
  2. [WPF] Imprimer sur plusieurs pages une ListBox
    Par UNi[FR] dans le forum C#
    Réponses: 1
    Dernier message: 04/12/2007, 14h42
  3. [WPF] Binding sur app.config
    Par despeludo dans le forum Windows Presentation Foundation
    Réponses: 2
    Dernier message: 24/10/2007, 22h56
  4. [WPF]DataTrigger sur ComboBox
    Par guitoux1 dans le forum Windows Forms
    Réponses: 11
    Dernier message: 20/06/2007, 10h31
  5. Informations sur un mode VESA
    Par Arnaudv6 dans le forum Assembleur
    Réponses: 6
    Dernier message: 05/04/2005, 20h46

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo