简体   繁体   中英

C# Directx App crashes in Release

When I run the Release for this code on any computer other than mine, I get the "Has Stopped Working" Error: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Microsoft.DirectX.DirectSound; using Microsoft.DirectX.AudioVideoPlayback; using Microsoft.DirectX; using 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();
        }
    }
}

Any ideas to why this happens?

here are the steps I would do to figure out the problem:

  1. Check if the video is present on the pc.
  2. Add a try catch block and check the output of the Exception.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM