2017-08-26 887 views
2

与合作:
的Visual Studio 2017年
.NET框架3.5
建设使用32位版本的VLC 2.2任何CPU
0.6
使用Vlc.DotNet(因为我认为这是唯一一个正在任何.NET框架...)VLC.DotNet System.ComponentModel.Win32Exception: '%1不是有效的Win32应用程序'

我创造了新的形式只是用于测试,如何库的工作方式(或者,如果作品)使用
“VlcControl”的拖放方法和一个按钮
所有代码如下:

Form.cs:

using System; 
using System.IO; 
using System.Windows.Forms; 

namespace WindowsFormsApp2 
{ 
    public partial class Form1 : Form 
    { 
     public Form1() 
     { 
      InitializeComponent(); 
     } 

     private void button1_Click(object sender, EventArgs e) 
     { 
      OpenFileDialog ofd = new OpenFileDialog 
      { 
       Filter = "(*.mp4) | *.mp4" 
      }; 

      if (ofd.ShowDialog() == DialogResult.OK) 
      { 
       vlcControl1.SetMedia(new FileInfo(Path.GetFileName(ofd.FileName))); 
       vlcControl1.Play(); 
      } 
     } 
    } 
} 

Form.Designer.cs(生成)

namespace WindowsFormsApp2 
{ 
    partial class Form1 
    { 
     /// <summary> 
     /// Required designer variable. 
     /// </summary> 
     private System.ComponentModel.IContainer components = null; 

     /// <summary> 
     /// Clean up any resources being used. 
     /// </summary> 
     /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 
     protected override void Dispose(bool disposing) 
     { 
      if (disposing && (components != null)) 
      { 
       components.Dispose(); 
      } 
      base.Dispose(disposing); 
     } 

     #region Windows Form Designer generated code 

     /// <summary> 
     /// Required method for Designer support - do not modify 
     /// the contents of this method with the code editor. 
     /// </summary> 
     private void InitializeComponent() 
     { 
      this.button1 = new System.Windows.Forms.Button(); 
      this.vlcControl1 = new Vlc.DotNet.Forms.VlcControl(); 
      ((System.ComponentModel.ISupportInitialize)(this.vlcControl1)).BeginInit(); 
      this.SuspendLayout(); 
      // 
      // button1 
      // 
      this.button1.Location = new System.Drawing.Point(12, 255); 
      this.button1.Name = "button1"; 
      this.button1.Size = new System.Drawing.Size(260, 42); 
      this.button1.TabIndex = 1; 
      this.button1.Text = "button1"; 
      this.button1.UseVisualStyleBackColor = true; 
      this.button1.Click += new System.EventHandler(this.button1_Click); 
      // 
      // vlcControl1 
      // 
      this.vlcControl1.BackColor = System.Drawing.Color.Black; 
      this.vlcControl1.Location = new System.Drawing.Point(12, 12); 
      this.vlcControl1.Name = "vlcControl1"; 
      this.vlcControl1.Size = new System.Drawing.Size(260, 237); 
      this.vlcControl1.Spu = -1; 
      this.vlcControl1.TabIndex = 2; 
      this.vlcControl1.Text = "vlcControl1"; 
      this.vlcControl1.VlcLibDirectory = new System.IO.DirectoryInfo("C:\\Program Files (x86)\\VideoLAN\\VLC"); 
      this.vlcControl1.VlcMediaplayerOptions = null; 
      // 
      // Form1 
      // 
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 
      this.ClientSize = new System.Drawing.Size(284, 309); 
      this.Controls.Add(this.vlcControl1); 
      this.Controls.Add(this.button1); 
      this.Name = "Form1"; 
      this.Text = "Form1"; 
      ((System.ComponentModel.ISupportInitialize)(this.vlcControl1)).EndInit(); 
      this.ResumeLayout(false); 
     } 

     #endregion 
     private System.Windows.Forms.Button button1; 
     private Vlc.DotNet.Forms.VlcControl vlcControl1; 
    } 
} 

的Program.cs

using System; 
using System.Windows.Forms; 

namespace WindowsFormsApp2 
{ 
    static class Program 
    { 
     [STAThread] 
     static void Main() 
     { 
      Application.EnableVisualStyles(); 
      Application.SetCompatibleTextRenderingDefault(false); 
      Application.Run(new Form1()); 
     } 
    } 
} 

现在的问题是:

调用 “的InitializeComponent()”,程序崩溃后:

在文件:Form.Designer.cs

线与: ((System.ComponentModel.ISupportInitialize)(this.vlcControl1))EndInit( );

抛出System.ComponentModel.Win32Exception: '%1不是有效的Win32应用程序'

我怎样才能解决这个问题???

+0

“using 32-bit VLC”。这不是AnyCPU,那是x86。 –

+0

选项设置为任何CPU 我已经知道这个应用程序将是x86,因为VLC –

回答

1

只需设置:Project-> Properties-> Build-> Platform Target = x86

+0

不可以...已经知道所有的64位VLC只是实验...请参阅Designer ...它已经设置为Program files(x86 )...(别名32位)... –

+0

尝试在项目构建设置中设置属性Platform Target = x86。 – MakS

+0

谢谢@MakS ...那可行...问题解决了... –

相关问题