2010-11-09 73 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