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

时间:2017-08-26 00:05:33

标签: c# vlc

使用:
Visual Studio 2017
NET框架3.5
为任何CPU建造 使用32位VLC版本2.2.6
使用Vlc.DotNet(因为我认为它只是一个正在使用任何.NET框架的...)

我创建了新表单,仅用于测试,此库如何工作(或者如果有效) 使用拖放方法进行" 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(Generated)

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

现在的问题是:

调用&#34; InitializeComponent()&#34;后,程序崩溃:

在档案中:Form.Designer.cs

符合: ((System.ComponentModel.ISupportInitialize)(this.vlcControl1))EndInit();

抛出 System.ComponentModel.Win32Exception :&#39; %1不是有效的Win32应用程序&#39;

我该如何解决?

1 个答案:

答案 0 :(得分:1)

设置:项目 - &gt;属性 - &GT;构建 - &gt;平台目标= x86