在测量过程中无法调用方法。 WPF

时间:2018-01-23 14:12:22

标签: wpf xaml exception

我的(WPF)应用程序抛出此异常并退出。而不是投票,试着帮助我,并要求您提供所需的任何信息:-)我只需要帮助“在措施正在进行时不能调用方法”如果有人知道为什么它被抛出会真的很有帮助。

Error Error: 0 : Timestamp: 1/19/2018 1:21:13 PM
Message: Unhandled Exception occured.
Category: Error
Priority: 2
EventId: 0
Severity: Error
Title:Dispatcher_UnhandledException(...) - App.xaml.cs
Machine: SomePC
App Domain: SoftwareNAme, Version=1.0, Culture=neutral, PublicKeyToken=null
ProcessId: 3524
Thread Name: 
Win32 ThreadId:1596
Extended Properties: Operating System - Microsoft Windows NT 6.2.9200.0
.NET Framework - 460805
Cannot call method while measure is in progress. - System.InvalidOperationException: Cannot call method while measure is in progress.
   at System.Windows.Controls.TextBlock.VerifyReentrancy()
   at System.Windows.Controls.TextBlock.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.DockPanel.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Border.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.DockPanel.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Control.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.DockPanel.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Border.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Border.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Decorator.MeasureOverride(Size constraint)
   at System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Border.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Window.MeasureOverrideHelper(Size constraint)
   at System.Windows.Window.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Interop.HwndSource.Process_WM_SIZE(UIElement rootUIElement, IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Interop.HwndSource.LayoutFilterMessage(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 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

在另一个实例中它抛出了异常,仍然没有显示UI

Exception has been thrown by the target of an invocation. - System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.SEHException: External component has thrown an exception.
   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, Object[] args)
   at System.Xaml.Schema.SafeReflectionInvoker.CreateInstanceCritical(Type type, Object[] arguments)
   at System.Xaml.Schema.XamlTypeInvoker.CreateInstance(Object[] arguments)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstance(XamlType xamlType, Object[] args)
   at MS.Internal.Xaml.Runtime.PartialTrustTolerantRuntime.CreateInstance(XamlType xamlType, Object[] args)
   at System.Xaml.XamlObjectWriter.Logic_CreateAndAssignToParentStart(ObjectWriterContext ctx)
   at System.Xaml.XamlObjectWriter.WriteStartMember(XamlMember property)
   at System.Windows.Markup.WpfXamlLoader.TransformNodes(XamlReader xamlReader, XamlObjectWriter xamlWriter, Boolean onlyLoadOneNode, Boolean skipJournaledProperties, Boolean shouldPassLineNumberInfo, IXamlLineInfo xamlLineInfo, IXamlLineInfoConsumer xamlLineInfoConsumer, XamlContextStack`1 stack, IStyleConnector styleConnector)
   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.DoStartup()
   at System.Windows.Application.<.ctor>b__1_0(Object unused)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
External component has thrown an exception. - System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.

XAML代码:

<src:WndBaseWindow
    x:Class="Gui.Windows.WndLogin"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:src="clr-namespace:Gui.Windows.BaseWindows"
    xmlns:resources="clr-namespace:Gui.Resources.Localization.Windows"
    xmlns:uc="clr-namespace:Gui.UserControls"
    xmlns:locGlobal="clr-namespace:Gui.Resources.Localization.Global"
    x:Name="This" Title="{x:Static resources:LoginResource.WindowTitleText}" ResizeMode="NoResize" Width="400"
    Height="300" SizeToContent="Manual" ShowInTaskbar="True"
    WindowStartupLocation="CenterScreen" KeyboardNavigation.TabNavigation="Cycle"
    FocusManager.FocusedElement="{Binding ElementName=tbUsername}"
    Icon="/somepath;component/Resources/Images/qgraph.ico"
    HelpUrl="{x:Static locGlobal:HelpUrlResource.LoginHelpPage}" Loaded="This_Loaded" KeyDown="This_KeyDown"
    Activated="This_Activated">
    <StackPanel>
        <Image x:Name="imgLogin" Source="/somepath;component/Resources/Images/LoginImage.png" HorizontalAlignment="Stretch" VerticalAlignment="Center" SnapsToDevicePixels="True" RenderOptions.BitmapScalingMode="Fant" />
        <DockPanel LastChildFill="False" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="{StaticResource LicensedForVersionBackgroundGradientBrush}" Height="28">
            <Label x:Name="lblLicence"  Foreground="White" Content="{x:Static resources:LoginResource.lblLicenceText}" DockPanel.Dock="Left"/>
            <Label x:Name="lblVersionNo" Foreground="White" DockPanel.Dock="Right" Content="{Binding Source={x:Static Application.Current}, Path=LicManager.ProductVersion}"/>
            <Label x:Name="lblVersion" Foreground="White" Content="{x:Static resources:LoginResource.lblVersionText}" DockPanel.Dock="Right"/>
            <Label DockPanel.Dock="Left" >
                <TextBlock Foreground="White" Text="{Binding Source={x:Static Application.Current}, Path=LicManager.LicensedFor}" TextTrimming="CharacterEllipsis"/>
            </Label>
        </DockPanel>
        <GroupBox x:Name="gbLogin" Header="{x:Static resources:LoginResource.gbLoginText}" HorizontalAlignment="Stretch" Margin="10,5">
            <Grid HorizontalAlignment="Stretch" Margin="20,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Label x:Name="lblUsername" Content="{x:Static resources:LoginResource.lblUsernameText}" Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" MinWidth="96"/>
                <uc:UcValidationTextBox MaxLines="1" x:Name="tbUsername" SpellCheck.IsEnabled="False" AcceptsReturn="False" Grid.Column="1" Grid.Row="0" VerticalAlignment="Stretch" TabIndex="0" TextChanged="tbUsername_TextChanged" />
                <Label x:Name="lblPassword" Content="{x:Static resources:LoginResource.lblPasswordText}" Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" MinWidth="96"/>
                <PasswordBox x:Name="pwbPassword" Grid.Column="1" Grid.Row="1" TabIndex="1" PasswordChanged="pwbPassword_PasswordChanged" />
                <Image Grid.Column="2" Grid.Row="1" ToolTipService.ToolTip="{x:Static resources:LoginResource.imgCapsLockOnTooltip}" Source="/somepath;component/Resources/Images/warning.ico" Style="{StaticResource toolbarImageStyle}"
                       Visibility="{Binding ElementName=This, Path=CapsLockOn, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource BooleanToVisibilityWithHiddenConverter}}" Height="25" Width="25" />
            </Grid>
        </GroupBox>
        <StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
            <Button x:Name="btnOk" Content="{x:Static resources:LoginResource.btnOkText}" Click="btnOk_Click" IsDefault="True" TabIndex="2" />
            <Button x:Name="btnCancel" Content="{x:Static resources:LoginResource.btnCancelText}" IsCancel="True"  TabIndex="3"/>
        </StackPanel>
    </StackPanel>
</src:WndBaseWindow>

0 个答案:

没有答案