2010-11-09 63 views
2

I'm新在這項工作,當我打開了一個項目,我得到這個錯誤,我可不是能找出what's回事。 有什麼幫助嗎?WPF設計視圖錯誤

SO:WinXP Sp3,Visual Studio 2010 Express

在此先感謝。

Exception not controlled. Details: System.Reflection.TargetInvocationException Se produjo una excepción en el destino de la invocación. en System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner) en System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner) en System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) en System.Delegate.DynamicInvokeImpl(Object[] args) en System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) en MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

System.NullReferenceException Referencia a objeto no establecida como instancia de un objeto. en ControlPesajeLavanderia.ItemParte.NuevoItemParte_IsVisibleChanged(Object sender, DependencyPropertyChangedEventArgs e) en C:\Documents and Settings\golaizola\Mis documentos\Visual Studio 2010\Projects\ControlPesajeLavanderia\ControlPesajeLavanderia\usercontrols\ItemParte.xaml.vb:línea 186 en System.Windows.UIElement.RaiseDependencyPropertyChanged(EventPrivateKey key, DependencyPropertyChangedEventArgs args) en System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) en System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) en System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) en System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) en System.Windows.UIElement.UpdateIsVisibleCache() en System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) en System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) en System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) en System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) en System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) en System.Windows.UIElement.UpdateIsVisibleCache() en System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) en System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) en System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) en System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) en System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) en System.Windows.UIElement.UpdateIsVisibleCache() en System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) en System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) en System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) en System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) en System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) en System.Windows.UIElement.UpdateIsVisibleCache() en System.Windows.UIElement.SynchronizeForceInheritProperties(UIElement uiElement, ContentElement contentElement, UIElement3D uiElement3D, DependencyObject parent) en System.Windows.UIElement.OnVisualParentChanged(DependencyObject oldParent) en System.Windows.FrameworkElement.OnVisualParentChanged(DependencyObject oldParent) en System.Windows.Media.Visual.FireOnVisualParentChanged(DependencyObject oldParent) en System.Windows.Media.Visual.AddVisualChild(Visual child) en System.Windows.FrameworkElement.set_TemplateChild(UIElement value) en System.Windows.Controls.ContentPresenter.UseContentTemplate.BuildVisualTree(FrameworkElement container) en System.Windows.StyleHelper.ApplyTemplateContent(UncommonField 1 dataField, DependencyObject container, FrameworkElementFactory templateRoot, Int32 lastChildIndex, HybridDictionary childIndexFromChildID, FrameworkTemplate frameworkTemplate) en System.Windows.FrameworkTemplate.ApplyTemplateContent(UncommonField 1 templateDataField, FrameworkElement container) en System.Windows.FrameworkElement.ApplyTemplate() en System.Windows.FrameworkElement.MeasureCore(Size availableSize) en System.Windows.UIElement.Measure(Size availableSize) en System.Windows.Controls.Border.MeasureOverride(Size constraint) en System.Windows.FrameworkElement.MeasureCore(Size availableSize) en System.Windows.UIElement.Measure(Size availableSize) en System.Windows.Controls.Control.MeasureOverride(Size constraint) en System.Windows.FrameworkElement.MeasureCore(Size availableSize) en System.Windows.UIElement.Measure(Size availableSize) en System.Windows.Controls.Border.MeasureOverride(Size constraint) en System.Windows.FrameworkElement.MeasureCore(Size availableSize) en System.Windows.UIElement.Measure(Size availableSize) en MS.Internal.Designer.ZoomableViewPresenter.DesignerBackground.MeasureOverride(Size constraint) en System.Windows.FrameworkElement.MeasureCore(Size availableSize) en System.Windows.UIElement.Measure(Size availableSize) en System.Windows.Controls.Decorator.MeasureOverride(Size constraint) en Microsoft.Windows.Design.Interaction.DesignerView.MeasureOverride(Size constraint) en System.Windows.FrameworkElement.MeasureCore(Size availableSize) en System.Windows.UIElement.Measure(Size availableSize) en MS.Internal.Designer.Viewport.MeasureOverride(Size availableSize) en System.Windows.FrameworkElement.MeasureCore(Size availableSize) en System.Windows.UIElement.Measure(Size availableSize) en MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint) en System.Windows.Controls.ScrollContentPresenter.MeasureOverride(Size constraint) en System.Windows.FrameworkElement.MeasureCore(Size availableSize) en System.Windows.UIElement.Measure(Size availableSize) en System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV) en System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV) en System.Windows.Controls.Grid.MeasureOverride(Size constraint) en System.Windows.FrameworkElement.MeasureCore(Size availableSize) en System.Windows.UIElement.Measure(Size availableSize) en System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint) en System.Windows.FrameworkElement.MeasureCore(Size availableSize) en System.Windows.UIElement.Measure(Size availableSize) en System.Windows.Controls.Grid.MeasureOverride(Size constraint) en System.Windows.FrameworkElement.MeasureCore(Size availableSize) en System.Windows.UIElement.Measure(Size availableSize) en MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint) en System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint) en System.Windows.FrameworkElement.MeasureCore(Size availableSize) en System.Windows.UIElement.Measure(Size availableSize) en System.Windows.Controls.Control.MeasureOverride(Size constraint) en System.Windows.FrameworkElement.MeasureCore(Size availableSize) en System.Windows.UIElement.Measure(Size availableSize) en System.Windows.Interop.HwndSource.SetLayoutSize() en System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value) en System.Windows.Interop.HwndSource.set_RootVisual(Visual value) en MS.Internal.DeferredHwndSource.ProcessQueue(Object sender, EventArgs e)

UPDATE:

我創建了一個新的形式和複製所有XAML,直到我得到的錯誤。

和錯誤說:當我包含在這一行我自己的用戶控件中出現錯誤。「對象引用不設置到對象的實例」

而且我不知道爲什麼...

+0

請問您能幫我們翻譯一下英文信息嗎? – 2010-11-09 12:59:44

+0

我認爲它是'對象引用未設置爲對象的實例'。 – mcm69 2010-11-09 13:06:44

回答

1

DEAR SWEET異常消息!你在某個構造函數中拋出一個異常,這很難從異常消息中知道哪裏;我正在根據TargetInvocationException作出這個判斷,這似乎總是表明這一點。

如果我是正確的,在你正在做的假設,構造的地方,一個變量不爲空。

通過每一個類你的解決方案你去檢查構造函數。對您觸摸的所有內容執行空檢查。如果不存在明顯的問題,請從設計器中實例化的類型中使用的任何構造函數中刪除邏輯。你最終會找到它。

2

如果你得到的錯誤(是的,它看起來像對象引用未設置)在設計視圖只,那麼我建議創建另一個空白表單,並通過片複製文本塊,直到您複製給你錯誤的文本。否則,您將不知道從哪裏開始診斷此錯誤。

這條線在此文件中可能有一些做的錯誤:

C:\ Documents和Settings \ golaizola \誤documentos \ Visual Studio 2010的\項目\ ControlPesajeLavanderia \ ControlPesajeLavanderia \用戶控件\ ItemParte.xaml。 vb

Line 186

+0

+1,因爲我認爲你發現了錯誤所在的正確路線。提問者應該看那條線,看看他們是否對某些不是空的假設作出了錯誤的假設。 – 2010-11-09 14:20:25

+0

這很有用。我創建了一個空白的用戶表單,並開始複製我的xaml直到出現錯誤。錯誤在這一行: 2010-11-09 14:28:57

+0

@Kioko,如果UcItemParte在_C中執行:\ Documents and Settings \ golaizola \ Mis documentos \ Visual Studio 2010 \ Projects \ ControlPesajeLavanderia \ ControlPesajeLavanderia \ usercontrols \ ItemParte.xaml.vb_,然後查看第186行 – 2010-11-09 14:31:37