Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6096767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:57:58+00:00 2026-05-23T12:57:58+00:00

I followed a tutorial on Video Player . It is nice but I am

  • 0

I followed a tutorial on Video Player.

It is nice but I am imagining a different situation.

I need to embed some videos in the Resources file and dynamically change the videos depending on the user input.
I have managed this running inside Visual Studio 2010. using the switch statements.
But I have to specify the path of that video in the resources file. for eg :

case 1 : video = new Video("..//..//Resources//The video name");

But when I publish this application using the click once wizard, the final application ends up in an exception :

System.NullReferenceException: Object reference not set to an instance of an object.
   at VideoPlayer.Form1.button2_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e).............

It seems that the video file was not included in the application.
But when i saw the installer folder, a clear look showed that there is a file as named VideoPlayer.exe.deploy which is of 59MB normally these files without any resources are light weighted…

It surely contains the Video file. But I cannot access that file.

How Do I Access It?

Please help me out…

Thanks in advance 🙂

As asked by some users, I am posting the entire code in C#.NET :

The Designer.cs File :

namespace PlayVideo
{
    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.viewport = new System.Windows.Forms.Panel();
            this.button1 = new System.Windows.Forms.Button();
            this.button2 = new System.Windows.Forms.Button();
            this.button3 = new System.Windows.Forms.Button();
            this.label1 = new System.Windows.Forms.Label();
            this.comboBox1 = new System.Windows.Forms.ComboBox();
            this.SuspendLayout();
            // 
            // viewport
            // 
            this.viewport.Location = new System.Drawing.Point(12, 39);
            this.viewport.Name = "viewport";
            this.viewport.Size = new System.Drawing.Size(391, 368);
            this.viewport.TabIndex = 0;
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(55, 418);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(79, 27);
            this.button1.TabIndex = 0;
            this.button1.Text = "Play";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            // 
            // button2
            // 
            this.button2.Location = new System.Drawing.Point(167, 418);
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(79, 27);
            this.button2.TabIndex = 1;
            this.button2.Text = "Pause";
            this.button2.UseVisualStyleBackColor = true;
            this.button2.Click += new System.EventHandler(this.button2_Click);
            // 
            // button3
            // 
            this.button3.Location = new System.Drawing.Point(279, 418);
            this.button3.Name = "button3";
            this.button3.Size = new System.Drawing.Size(79, 27);
            this.button3.TabIndex = 2;
            this.button3.Text = "Stop";
            this.button3.UseVisualStyleBackColor = true;
            this.button3.Click += new System.EventHandler(this.button3_Click);
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(12, 15);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(108, 13);
            this.label1.TabIndex = 3;
            this.label1.Text = "Load Video number : ";
            // 
            // comboBox1
            // 
            this.comboBox1.FormattingEnabled = true;
            this.comboBox1.Items.AddRange(new object[] {
            "Video number 1",
            "Video number 2",
            "Video number 3"});
            this.comboBox1.Location = new System.Drawing.Point(132, 12);
            this.comboBox1.Name = "comboBox1";
            this.comboBox1.Size = new System.Drawing.Size(121, 21);
            this.comboBox1.TabIndex = 4;
            this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(415, 457);
            this.Controls.Add(this.comboBox1);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.button3);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.viewport);
            this.Name = "Form1";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Video Player";
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Panel viewport;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.Button button2;
        private System.Windows.Forms.Button button3;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.ComboBox comboBox1;
    }
}

And the other .cs file is :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.DirectX.AudioVideoPlayback;

namespace PlayVideo
{
    public partial class Form1 : Form
    {
        private Video video;
        public Form1()
        {
            InitializeComponent();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox1.SelectedIndex)
            {
                case 0: video = new Video("..//..//Resources//Video1.mp4");
                        break;
                case 1: video = new Video("..//..//Resources//Video2.DAT");
                        break;
                case 2: video = new Video("..//..//Resources//Video3.DAT");
                        break;
            }
            int width = viewport.Width;
            int height = viewport.Height;
            // set the panel as the video object’s owner
            video.Owner = viewport;

            // stop the video
            video.Stop();

            // resize the video to the size original size of the panel
            viewport.Size = new Size(width, height);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (video.State != StateFlags.Running)
            {
                video.Play();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (video.State == StateFlags.Running)
            {
                video.Pause();
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (video.State != StateFlags.Stopped)
            {
                video.Stop();
            }
        }
    }
}

And I thought a screenshot may be of some information :

enter image description here

It works fine in Debugging mode….. But once I install it using the click once installer, It crashes into an Exception. How do I manage the same using the Resources in the DEPLOY file?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:57:58+00:00Added an answer on May 23, 2026 at 12:57 pm

    You are referencing the files in your VS solution, which works fine, when debugging the application, since the paths are valid from your project’s \bin\debug folder. If you’ve set the build-action for the resources to “Embedded Resource”, you can access those files using:

    typeof(Form1).Assembly.GetManifestResourceStream("PlayVideo.Resources.Video1.dat");
    

    MSDN: http://msdn.microsoft.com/en-us/library/xc4235zt.aspx

    Update
    I’ve confirmed that the Video class won’t accept a Stream and that the res://-Protocol cannot be used either. I would suggest, that you don’t embed the videos into the executable, but place them into the Application directory. You can change the build-action of the video-files to none and change the “Copy to Output Directory” property to “Copy If Newer”. Once the application is built, all videos are put in the output directory, which you can deploy along with the executable. You should then use your initial approach, but use a path like “The video name.dat” rather than “..//..//Resources/The video name.dat”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I followed this tutorial , and included a video player in my app. But
I followed this tutorial, for now it's working nice, but i only have a
I've followed the tutorial here to load video files into a C program. But
I've followed this tutorial: http://anandhansubbiah.com/blog/writing-your-first-android-application/ , but no matter what I do, and what
I am working on Windows Azure. I followed some tutorial about how to store
I followed the RailsCasts tutorial to do a simple search with autocomplete, but it
I followed the tutorial here but when I create the project in Eclipse, i
I have been working with Xcode 4.2.1, but following some tutorials and videos from
I followed tutorial from cocos2d official site . I try to create some items
I followed several tutorial to make this work, but I can't get draggable items.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.