2017-01-16 99 views
0

当我在除我以外的任何计算机上运行此代码的发行版时,出现“已停止工作”错误: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing;使用System.Linq的 ; using System.Text; using System.Threading.Tasks;使用System.Windows.Forms的 ; 使用Microsoft.DirectX.DirectSound; using Microsoft.DirectX.AudioVideoPlayback;使用Microsoft.DirectX的 ; using System.Diagnostics;C#Directx应用程序崩溃版本

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

为什么发生这种情况的任何想法?

+0

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

回答

0

这里是我会做找出问题的步骤:

  1. 检查视频出现在PC上。
  2. 添加try catch块并检查Exception的输出。