none
Visual Studio exception: "Value cannot be null. Parameter name: path"

    Question

  • After building and compiling a user control, I added it to a C# Windows application.  Everything worked. 

    Then suddenly, a VS exception window popped up (and continues to do so).  It has no title in the title bar.  The window reads, "Value cannot be null.  Parameter name:  path". 

    This exception pops up whether I load the appplication **or** I select View Design in Solution Explorer to look at my user control code.  My application doesn't need run to have Visual Studio pop up this exception!

    I find no string that causes this issue.  Break points in catch sections never trip because the code isn't executed.

    The exception appears to occur in behind-the-scene code that executes when I click on the View Design within Solution Explorer.  Incidentally, when I delete the control from the application, the exception disappears.

    I've enclosed the code.  (P.S.  I'm using VS 2003; yes, I know.)  I appreciate your assistance.

     

    Code Snippet

    using System;

    using System.Collections;

    using System.ComponentModel;

    using System.Configuration;

    using System.Drawing;

    using System.Data;

    using System.IO;

    using System.Windows.Forms;

    namespace VS_ETL_DATES_FORM

    {

    /// <summary>

    /// Summary description for SQLSelectionCriteria.

    /// </summary>

    public class SQLSelectionCriteria : System.Windows.Forms.UserControl

    {

    static private string m_szInputLocationPath = null;

    static private string m_szInputSearchCriterian = null;

    private System.Windows.Forms.ListBox ChosenListBox;

    private System.Windows.Forms.Button DownChosenArrowButton;

    private System.Windows.Forms.Button DownOptionsArrowButton;

    private System.Windows.Forms.Button LeftArrowButton;

    private System.Windows.Forms.ListBox OptionsListBox;

    private System.Windows.Forms.Button RightArrowButton;

    private System.Windows.Forms.Button UpChosenArrowButton;

    private System.Windows.Forms.Button UpOptionsArrowButton;

    enum eListBox { OptionsListBox, ChosenListBox };

    /// <summary>

    /// Required designer variable.

    /// </summary>

    private System.ComponentModel.Container components = null;

    public SQLSelectionCriteria()

    {

    // This call is required by the Windows.Forms Form Designer.

    InitializeComponent();

    // TODO: Add any initialization after the InitializeComponent call

    }

    /// <summary>

    /// Clean up any resources being used.

    /// </summary>

    protected override void Dispose( bool disposing )

    {

    if( disposing )

    {

    if(components != null)

    {

    components.Dispose();

    }

    }

    base.Dispose( disposing );

    }

    #region Component 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()

    {

    System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(SQLSelectionCriteria));

    this.OptionsListBox = new System.Windows.Forms.ListBox();

    this.ChosenListBox = new System.Windows.Forms.ListBox();

    this.UpOptionsArrowButton = new System.Windows.Forms.Button();

    this.DownOptionsArrowButton = new System.Windows.Forms.Button();

    this.RightArrowButton = new System.Windows.Forms.Button();

    this.LeftArrowButton = new System.Windows.Forms.Button();

    this.UpChosenArrowButton = new System.Windows.Forms.Button();

    this.DownChosenArrowButton = new System.Windows.Forms.Button();

    this.SuspendLayout();

    //

    // OptionsListBox

    //

    this.OptionsListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)

    | System.Windows.Forms.AnchorStyles.Left)

    | System.Windows.Forms.AnchorStyles.Right)));

    this.OptionsListBox.HorizontalExtent = 8;

    this.OptionsListBox.HorizontalScrollbar = true;

    this.OptionsListBox.Location = new System.Drawing.Point(40, 8);

    this.OptionsListBox.Name = "OptionsListBox";

    this.OptionsListBox.Size = new System.Drawing.Size(266, 134);

    this.OptionsListBox.TabIndex = 3;

    //

    // ChosenListBox

    //

    this.ChosenListBox.HorizontalExtent = 128;

    this.ChosenListBox.HorizontalScrollbar = true;

    this.ChosenListBox.Location = new System.Drawing.Point(418, 8);

    this.ChosenListBox.Name = "ChosenListBox";

    this.ChosenListBox.Size = new System.Drawing.Size(266, 134);

    this.ChosenListBox.TabIndex = 6;

    //

    // UpOptionsArrowButton

    //

    this.UpOptionsArrowButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)

    | System.Windows.Forms.AnchorStyles.Left)

    | System.Windows.Forms.AnchorStyles.Right)));

    this.UpOptionsArrowButton.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("UpOptionsArrowButton.BackgroundImage")));

    this.UpOptionsArrowButton.Location = new System.Drawing.Point(8, 24);

    this.UpOptionsArrowButton.Name = "UpOptionsArrowButton";

    this.UpOptionsArrowButton.Size = new System.Drawing.Size(23, 40);

    this.UpOptionsArrowButton.TabIndex = 0;

    this.UpOptionsArrowButton.Click += new System.EventHandler(this.UpOptionsArrowButton_Click);

    //

    // DownOptionsArrowButton

    //

    this.DownOptionsArrowButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)

    | System.Windows.Forms.AnchorStyles.Left)

    | System.Windows.Forms.AnchorStyles.Right)));

    this.DownOptionsArrowButton.BackColor = System.Drawing.Color.Black;

    this.DownOptionsArrowButton.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("DownOptionsArrowButton.BackgroundImage")));

    this.DownOptionsArrowButton.Location = new System.Drawing.Point(8, 86);

    this.DownOptionsArrowButton.Name = "DownOptionsArrowButton";

    this.DownOptionsArrowButton.Size = new System.Drawing.Size(23, 40);

    this.DownOptionsArrowButton.TabIndex = 1;

    this.DownOptionsArrowButton.Click += new System.EventHandler(this.DownOptionsArrowButton_Click);

    //

    // RightArrowButton

    //

    this.RightArrowButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)

    | System.Windows.Forms.AnchorStyles.Left)

    | System.Windows.Forms.AnchorStyles.Right)));

    this.RightArrowButton.BackColor = System.Drawing.Color.Black;

    this.RightArrowButton.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("RightArrowButton.BackgroundImage")));

    this.RightArrowButton.Location = new System.Drawing.Point(314, 29);

    this.RightArrowButton.Name = "RightArrowButton";

    this.RightArrowButton.Size = new System.Drawing.Size(96, 23);

    this.RightArrowButton.TabIndex = 4;

    this.RightArrowButton.Click += new System.EventHandler(this.RightArrowButton_Click);

    //

    // LeftArrowButton

    //

    this.LeftArrowButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)

    | System.Windows.Forms.AnchorStyles.Left)

    | System.Windows.Forms.AnchorStyles.Right)));

    this.LeftArrowButton.BackColor = System.Drawing.Color.Black;

    this.LeftArrowButton.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("LeftArrowButton.BackgroundImage")));

    this.LeftArrowButton.Location = new System.Drawing.Point(314, 108);

    this.LeftArrowButton.Name = "LeftArrowButton";

    this.LeftArrowButton.Size = new System.Drawing.Size(96, 23);

    this.LeftArrowButton.TabIndex = 10;

    this.LeftArrowButton.Click += new System.EventHandler(this.LeftArrowButton_Click);

    //

    // UpChosenArrowButton

    //

    this.UpChosenArrowButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)

    | System.Windows.Forms.AnchorStyles.Left)

    | System.Windows.Forms.AnchorStyles.Right)));

    this.UpChosenArrowButton.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("UpChosenArrowButton.BackgroundImage")));

    this.UpChosenArrowButton.Location = new System.Drawing.Point(692, 24);

    this.UpChosenArrowButton.Name = "UpChosenArrowButton";

    this.UpChosenArrowButton.Size = new System.Drawing.Size(23, 40);

    this.UpChosenArrowButton.TabIndex = 7;

    this.UpChosenArrowButton.Click += new System.EventHandler(this.UpChosenArrowButton_Click);

    //

    // DownChosenArrowButton

    //

    this.DownChosenArrowButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)

    | System.Windows.Forms.AnchorStyles.Left)

    | System.Windows.Forms.AnchorStyles.Right)));

    this.DownChosenArrowButton.BackColor = System.Drawing.Color.Black;

    this.DownChosenArrowButton.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("DownChosenArrowButton.BackgroundImage")));

    this.DownChosenArrowButton.Location = new System.Drawing.Point(692, 86);

    this.DownChosenArrowButton.Name = "DownChosenArrowButton";

    this.DownChosenArrowButton.Size = new System.Drawing.Size(23, 40);

    this.DownChosenArrowButton.TabIndex = 8;

    this.DownChosenArrowButton.Click += new System.EventHandler(this.DownChosenArrowButton_Click);

    //

    // SQLSelectionCriteria

    //

    this.BackColor = System.Drawing.Color.Black;

    this.Controls.Add(this.DownChosenArrowButton);

    this.Controls.Add(this.UpChosenArrowButton);

    this.Controls.Add(this.LeftArrowButton);

    this.Controls.Add(this.RightArrowButton);

    this.Controls.Add(this.DownOptionsArrowButton);

    this.Controls.Add(this.UpOptionsArrowButton);

    this.Controls.Add(this.ChosenListBox);

    this.Controls.Add(this.OptionsListBox);

    this.Name = "SQLSelectionCriteria";

    this.Size = new System.Drawing.Size(724, 160);

    this.Load += new System.EventHandler(this.SQLSelectionCriteria_Load);

    this.ResumeLayout(false);

    }

    #endregion

    }

    }

     

     

     

    Friday, October 10, 2008 3:40 PM

Answers

  • It's probably your Load event handler (SQLSelectionCriteria_Load).  Wrap it like this:

      if (!this.DesignMode) {
        // Your original code
        //...
      }
    Saturday, October 11, 2008 8:01 PM

All replies

  • It's probably your Load event handler (SQLSelectionCriteria_Load).  Wrap it like this:

      if (!this.DesignMode) {
        // Your original code
        //...
      }
    Saturday, October 11, 2008 8:01 PM
  •  

    That seems to have taken care of it.  I haven't had the window pop up since I made the change. 

     

    Great insight!  Thank you.

     

    Monday, October 13, 2008 6:17 PM