Skip to content

GifImage控件 Dispose 后设置 Visible 引发 GdiplusInvalidParameter 异常 #680

@hitchao

Description

@hitchao

GifImage控件Dispose 后设置visible 引发 GdiplusInvalidParameter 异常

  • GifImage 在 dispose 并 Hidden 之后,再次设置 Visible 会导致 GdiplusInvalidParameter
  • 从左到右依次点击按钮

Environment

  • .net: 4.7.2
  • IDE vs2019
  • Version 3.0.0

XAML:

<StackPanel Margin="10"> 
    <hc:GifImage x:Name="GifImage" Width="500" Height="300" Margin="10"/>
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
        <Button Height="50" Width="100" HorizontalAlignment="Center" Content="Load" Click="Button_Click"/>
        <Button Height="50" Width="100" HorizontalAlignment="Center" Content="Dispose" Click="Button_Click_1"/>
        <Button Height="50" Width="100" HorizontalAlignment="Center" Content="Hidden" Click="Button_Click_2"/>
        <Button Height="50" Width="100" HorizontalAlignment="Center" Content="Visible" Click="Button_Click_3"/>
    </StackPanel>
</StackPanel>

CS:

string gifpath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test.gif");
private void Button_Click(object sender, RoutedEventArgs e)
{
    GifImage.Uri = new Uri($"pack://siteoforigin:,,,/{gifpath}");
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
    GifImage.Dispose();
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
    GifImage.Visibility = Visibility.Hidden;
}
private void Button_Click_3(object sender, RoutedEventArgs e)
{
    //GifImage.Uri = new Uri(GifImage.Uri.OriginalString);
    GifImage.Visibility = Visibility.Visible;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions