首页 文章

C#Directx App在Release中崩溃

提问于
浏览
0

当我在除我的任何计算机上运行此代码的版本时,我得到“已停止工作”错误:使用系统;使用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();
        }
    }
}

有什么想法为什么会这样?

1 回答

  • 0

    以下是我要解决问题的步骤:

    • 检查电脑上是否有视频 .

    • 添加try catch块并检查Exception的输出 .

相关问题