Skip to content

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

Closed

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;
}

Activity

  1. simadi commented on May 20, 2023

    @simadi

    我也遇到了这个问题怎么解决?3.4版本

  2. Farb commented on Jul 12, 2023

    @Farb

    我也遇到这个问题了 ,3.4版本。这样启动的时候直接报错了
    <hc:GifImage x:Name="GifImageMain" Stretch="None" Margin="5" Uri="/2.gif" />

  3. added a commit that references this issue on Mar 28, 2024
    ebcb709
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      ⌂ 换网址