【问题标题】:C# Directx App crashes in ReleaseC# Directx App 在 Release 中崩溃
【发布时间】:2017-05-31 14:30:37
【问题描述】:

当我在我以外的任何计算机上运行此代码的发行版时,我收到“已停止工作”错误: 使用系统; 使用 System.Collections.Generic; 使用 System.ComponentModel; 使用 System.Data; 使用 System.Drawing; 使用 System.Linq; 使用 System.Text; 使用 System.Threading.Tasks; 使用 System.Windows.Forms; 使用 Microsoft.DirectX.DirectSound; 使用 Microsoft.DirectX.AudioVideoPlayback; 使用 Microsoft.DirectX; 使用 System.Diagnostics;

namespace Picture_Button
{
    public partial class Form1 : Form
    {
        Video video = new Video("C:\\Users\\Pushkin\\Desktop\\PPAP.mp4");
        //Video video = new Video("C:\\Users\\Pushkin\\Desktop\\PPAP.mp4");
        private int clicks = 0;
        public Form1()
        {
            InitializeComponent();
            pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
            video.Ending += new System.EventHandler(this.Video_Ending);
            //video.Ending += Video_Ending;
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            clicks++;
        }

        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            switch (clicks)
            {
                case 0: pictureBox1.Image = Properties.Resources.Pineapple; break;
                case 1: pictureBox1.Image = Properties.Resources.Apple; break;
                case 2: pictureBox1.Image = Properties.Resources.Pen; break;
                case 3:
                    {
                        video.Owner = this;
                        video.Play();
                        /*video.Dispose();
                        Application.Exit();*/
                    }
                    break;
            }
        }
        private void Video_Ending(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            video.Dispose();
            Application.Exit();
        }
    }
}

对为什么会发生这种情况有任何想法吗?

【问题讨论】:

  • 请检查 Windows 事件日志。您很可能会在那里找到更详细的错误消息。将其作为问题的一部分发布在这里

标签: c# directx


【解决方案1】:

以下是解决问题的步骤:

  1. 检查视频是否存在于电脑上。
  2. 添加 try catch 块并检查异常的输出。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-25
    • 1970-01-01
    相关资源
    最近更新 更多