locked
ArgumentException (Illegal characters in path) RRS feed

  • Question

  • When i start new windows forms applicaion and drag a datagrid view on to the form it is binding properly and shows data by clicking "Preview data" on binding source. But when i attempt to debug it does not show any data on datagrid. If i try to add data and save , it throws an exception such as 

    "An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
    Additional information: Illegal characters in path."

    I am using SQL server Ce 4.0 database and there is no error in database path

    My appconfig shows connection string as follows.

    connectionString="Data Source=|DataDirectory|\txt.sdf" providerName="Microsoft.SqlServerCe.Client.4.0" />

    Previously i have created few projects in which this type of exception was not observed. Please provide a solution for this as the exception was thrown everytime i start a new project.

    Thank u

    Wednesday, February 19, 2014 3:54 AM

Answers

  • Hi !

          Finally i solved my problem by checking various points. Since a simple project with a single form and dataset throws the exception, there is nothing wrong in the code. The connection string is also in right format and no error in path. There is no issue regarding naming the files. I have tried by unistalling and re-install .net framework 4.5 but it was not solved. Finally i unistalled and re-installed sql server compact 4.0 sp1 which solved my problem. Now new projects are working fine, ofcourse those projects created previously are still throwing same expression. I think there is a problem with SQL server compact 4.0 sp1 previously installed which may be corrupted. Thank you for attention and reply to my query.

    • Marked as answer by Marvin_Guo Friday, February 28, 2014 5:34 AM
    Wednesday, February 26, 2014 4:11 PM

All replies

  • Hi,

    >>"An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
    Additional information: Illegal characters in path."

    Which line of code throw this exception? Could you show me your code or upload your project?

    I suggest you to create break point and debug your application,You need to pay special attention to those statements contain path string.

    Mark sure your path string follow file naming conventions and rules :

    http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, February 20, 2014 5:18 AM
  • Hi !

    Thank  you for reply. Here by i am attaching my simple demo project in which i am getting the exception when saving the data.

    The call stack of the exception is as follows

    > MyApp.exe!MyApp.Form1.Form1_Load(Object sender, System.EventArgs e) Line 12 + 0x3d bytes Basic

    The attached project name is MyApp and database is TextDb.

    Thank u

    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Partial Class Form1
        Inherits System.Windows.Forms.Form
    
        'Form overrides dispose to clean up the component list.
        <System.Diagnostics.DebuggerNonUserCode()> _
        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            Try
                If disposing AndAlso components IsNot Nothing Then
                    components.Dispose()
                End If
            Finally
                MyBase.Dispose(disposing)
            End Try
        End Sub
    
        'Required by the Windows Form Designer
        Private components As System.ComponentModel.IContainer
    
        'NOTE: The following procedure is required by the Windows Form Designer
        'It can be modified using the Windows Form Designer.  
        'Do not modify it using the code editor.
        <System.Diagnostics.DebuggerStepThrough()> _
        Private Sub InitializeComponent()
            Me.components = New System.ComponentModel.Container()
            Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
            Me.TestDbDataSet = New MyApp.TestDbDataSet()
            Me.TxtDataBindingSource = New System.Windows.Forms.BindingSource(Me.components)
            Me.TxtDataTableAdapter = New MyApp.TestDbDataSetTableAdapters.TxtDataTableAdapter()
            Me.TableAdapterManager = New MyApp.TestDbDataSetTableAdapters.TableAdapterManager()
            Me.TxtDataBindingNavigator = New System.Windows.Forms.BindingNavigator(Me.components)
            Me.BindingNavigatorMoveFirstItem = New System.Windows.Forms.ToolStripButton()
            Me.BindingNavigatorMovePreviousItem = New System.Windows.Forms.ToolStripButton()
            Me.BindingNavigatorSeparator = New System.Windows.Forms.ToolStripSeparator()
            Me.BindingNavigatorPositionItem = New System.Windows.Forms.ToolStripTextBox()
            Me.BindingNavigatorCountItem = New System.Windows.Forms.ToolStripLabel()
            Me.BindingNavigatorSeparator1 = New System.Windows.Forms.ToolStripSeparator()
            Me.BindingNavigatorMoveNextItem = New System.Windows.Forms.ToolStripButton()
            Me.BindingNavigatorMoveLastItem = New System.Windows.Forms.ToolStripButton()
            Me.BindingNavigatorSeparator2 = New System.Windows.Forms.ToolStripSeparator()
            Me.BindingNavigatorAddNewItem = New System.Windows.Forms.ToolStripButton()
            Me.BindingNavigatorDeleteItem = New System.Windows.Forms.ToolStripButton()
            Me.TxtDataBindingNavigatorSaveItem = New System.Windows.Forms.ToolStripButton()
            Me.TxtDataDataGridView = New System.Windows.Forms.DataGridView()
            Me.DataGridViewTextBoxColumn1 = New System.Windows.Forms.DataGridViewTextBoxColumn()
            Me.DataGridViewTextBoxColumn2 = New System.Windows.Forms.DataGridViewTextBoxColumn()
            Me.DataGridViewTextBoxColumn3 = New System.Windows.Forms.DataGridViewTextBoxColumn()
            CType(Me.TestDbDataSet, System.ComponentModel.ISupportInitialize).BeginInit()
            CType(Me.TxtDataBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
            CType(Me.TxtDataBindingNavigator, System.ComponentModel.ISupportInitialize).BeginInit()
            Me.TxtDataBindingNavigator.SuspendLayout()
            CType(Me.TxtDataDataGridView, System.ComponentModel.ISupportInitialize).BeginInit()
            Me.SuspendLayout()
            '
            'TestDbDataSet
            '
            Me.TestDbDataSet.DataSetName = "TestDbDataSet"
            Me.TestDbDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
            '
            'TxtDataBindingSource
            '
            Me.TxtDataBindingSource.DataMember = "TxtData"
            Me.TxtDataBindingSource.DataSource = Me.TestDbDataSet
            '
            'TxtDataTableAdapter
            '
            Me.TxtDataTableAdapter.ClearBeforeFill = True
            '
            'TableAdapterManager
            '
            Me.TableAdapterManager.BackupDataSetBeforeUpdate = False
            Me.TableAdapterManager.TxtDataTableAdapter = Me.TxtDataTableAdapter
            Me.TableAdapterManager.UpdateOrder = MyApp.TestDbDataSetTableAdapters.TableAdapterManager.UpdateOrderOption.InsertUpdateDelete
            '
            'TxtDataBindingNavigator
            '
            Me.TxtDataBindingNavigator.AddNewItem = Me.BindingNavigatorAddNewItem
            Me.TxtDataBindingNavigator.BindingSource = Me.TxtDataBindingSource
            Me.TxtDataBindingNavigator.CountItem = Me.BindingNavigatorCountItem
            Me.TxtDataBindingNavigator.DeleteItem = Me.BindingNavigatorDeleteItem
            Me.TxtDataBindingNavigator.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BindingNavigatorMoveFirstItem, Me.BindingNavigatorMovePreviousItem, Me.BindingNavigatorSeparator, Me.BindingNavigatorPositionItem, Me.BindingNavigatorCountItem, Me.BindingNavigatorSeparator1, Me.BindingNavigatorMoveNextItem, Me.BindingNavigatorMoveLastItem, Me.BindingNavigatorSeparator2, Me.BindingNavigatorAddNewItem, Me.BindingNavigatorDeleteItem, Me.TxtDataBindingNavigatorSaveItem})
            Me.TxtDataBindingNavigator.Location = New System.Drawing.Point(0, 0)
            Me.TxtDataBindingNavigator.MoveFirstItem = Me.BindingNavigatorMoveFirstItem
            Me.TxtDataBindingNavigator.MoveLastItem = Me.BindingNavigatorMoveLastItem
            Me.TxtDataBindingNavigator.MoveNextItem = Me.BindingNavigatorMoveNextItem
            Me.TxtDataBindingNavigator.MovePreviousItem = Me.BindingNavigatorMovePreviousItem
            Me.TxtDataBindingNavigator.Name = "TxtDataBindingNavigator"
            Me.TxtDataBindingNavigator.PositionItem = Me.BindingNavigatorPositionItem
            Me.TxtDataBindingNavigator.Size = New System.Drawing.Size(503, 25)
            Me.TxtDataBindingNavigator.TabIndex = 0
            Me.TxtDataBindingNavigator.Text = "BindingNavigator1"
            '
            'BindingNavigatorMoveFirstItem
            '
            Me.BindingNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorMoveFirstItem.Image = CType(resources.GetObject("BindingNavigatorMoveFirstItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorMoveFirstItem.Name = "BindingNavigatorMoveFirstItem"
            Me.BindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorMoveFirstItem.Size = New System.Drawing.Size(23, 22)
            Me.BindingNavigatorMoveFirstItem.Text = "Move first"
            '
            'BindingNavigatorMovePreviousItem
            '
            Me.BindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorMovePreviousItem.Image = CType(resources.GetObject("BindingNavigatorMovePreviousItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorMovePreviousItem.Name = "BindingNavigatorMovePreviousItem"
            Me.BindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorMovePreviousItem.Size = New System.Drawing.Size(23, 22)
            Me.BindingNavigatorMovePreviousItem.Text = "Move previous"
            '
            'BindingNavigatorSeparator
            '
            Me.BindingNavigatorSeparator.Name = "BindingNavigatorSeparator"
            Me.BindingNavigatorSeparator.Size = New System.Drawing.Size(6, 25)
            '
            'BindingNavigatorPositionItem
            '
            Me.BindingNavigatorPositionItem.AccessibleName = "Position"
            Me.BindingNavigatorPositionItem.AutoSize = False
            Me.BindingNavigatorPositionItem.Name = "BindingNavigatorPositionItem"
            Me.BindingNavigatorPositionItem.Size = New System.Drawing.Size(50, 23)
            Me.BindingNavigatorPositionItem.Text = "0"
            Me.BindingNavigatorPositionItem.ToolTipText = "Current position"
            '
            'BindingNavigatorCountItem
            '
            Me.BindingNavigatorCountItem.Name = "BindingNavigatorCountItem"
            Me.BindingNavigatorCountItem.Size = New System.Drawing.Size(35, 15)
            Me.BindingNavigatorCountItem.Text = "of {0}"
            Me.BindingNavigatorCountItem.ToolTipText = "Total number of items"
            '
            'BindingNavigatorSeparator1
            '
            Me.BindingNavigatorSeparator1.Name = "BindingNavigatorSeparator"
            Me.BindingNavigatorSeparator1.Size = New System.Drawing.Size(6, 6)
            '
            'BindingNavigatorMoveNextItem
            '
            Me.BindingNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorMoveNextItem.Image = CType(resources.GetObject("BindingNavigatorMoveNextItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorMoveNextItem.Name = "BindingNavigatorMoveNextItem"
            Me.BindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorMoveNextItem.Size = New System.Drawing.Size(23, 20)
            Me.BindingNavigatorMoveNextItem.Text = "Move next"
            '
            'BindingNavigatorMoveLastItem
            '
            Me.BindingNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorMoveLastItem.Image = CType(resources.GetObject("BindingNavigatorMoveLastItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorMoveLastItem.Name = "BindingNavigatorMoveLastItem"
            Me.BindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorMoveLastItem.Size = New System.Drawing.Size(23, 20)
            Me.BindingNavigatorMoveLastItem.Text = "Move last"
            '
            'BindingNavigatorSeparator2
            '
            Me.BindingNavigatorSeparator2.Name = "BindingNavigatorSeparator"
            Me.BindingNavigatorSeparator2.Size = New System.Drawing.Size(6, 6)
            '
            'BindingNavigatorAddNewItem
            '
            Me.BindingNavigatorAddNewItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorAddNewItem.Image = CType(resources.GetObject("BindingNavigatorAddNewItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorAddNewItem.Name = "BindingNavigatorAddNewItem"
            Me.BindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorAddNewItem.Size = New System.Drawing.Size(23, 22)
            Me.BindingNavigatorAddNewItem.Text = "Add new"
            '
            'BindingNavigatorDeleteItem
            '
            Me.BindingNavigatorDeleteItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorDeleteItem.Image = CType(resources.GetObject("BindingNavigatorDeleteItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorDeleteItem.Name = "BindingNavigatorDeleteItem"
            Me.BindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorDeleteItem.Size = New System.Drawing.Size(23, 20)
            Me.BindingNavigatorDeleteItem.Text = "Delete"
            '
            'TxtDataBindingNavigatorSaveItem
            '
            Me.TxtDataBindingNavigatorSaveItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.TxtDataBindingNavigatorSaveItem.Image = CType(resources.GetObject("TxtDataBindingNavigatorSaveItem.Image"), System.Drawing.Image)
            Me.TxtDataBindingNavigatorSaveItem.Name = "TxtDataBindingNavigatorSaveItem"
            Me.TxtDataBindingNavigatorSaveItem.Size = New System.Drawing.Size(23, 23)
            Me.TxtDataBindingNavigatorSaveItem.Text = "Save Data"
            '
            'TxtDataDataGridView
            '
            Me.TxtDataDataGridView.AutoGenerateColumns = False
            Me.TxtDataDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
            Me.TxtDataDataGridView.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.DataGridViewTextBoxColumn1, Me.DataGridViewTextBoxColumn2, Me.DataGridViewTextBoxColumn3})
            Me.TxtDataDataGridView.DataSource = Me.TxtDataBindingSource
            Me.TxtDataDataGridView.Location = New System.Drawing.Point(81, 100)
            Me.TxtDataDataGridView.Name = "TxtDataDataGridView"
            Me.TxtDataDataGridView.Size = New System.Drawing.Size(300, 220)
            Me.TxtDataDataGridView.TabIndex = 1
            '
            'DataGridViewTextBoxColumn1
            '
            Me.DataGridViewTextBoxColumn1.DataPropertyName = "ID"
            Me.DataGridViewTextBoxColumn1.HeaderText = "ID"
            Me.DataGridViewTextBoxColumn1.Name = "DataGridViewTextBoxColumn1"
            Me.DataGridViewTextBoxColumn1.ReadOnly = True
            '
            'DataGridViewTextBoxColumn2
            '
            Me.DataGridViewTextBoxColumn2.DataPropertyName = "TxtName"
            Me.DataGridViewTextBoxColumn2.HeaderText = "TxtName"
            Me.DataGridViewTextBoxColumn2.Name = "DataGridViewTextBoxColumn2"
            '
            'DataGridViewTextBoxColumn3
            '
            Me.DataGridViewTextBoxColumn3.DataPropertyName = "Remarks"
            Me.DataGridViewTextBoxColumn3.HeaderText = "Remarks"
            Me.DataGridViewTextBoxColumn3.Name = "DataGridViewTextBoxColumn3"
            '
            'Form1
            '
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.ClientSize = New System.Drawing.Size(503, 433)
            Me.Controls.Add(Me.TxtDataDataGridView)
            Me.Controls.Add(Me.TxtDataBindingNavigator)
            Me.Name = "Form1"
            Me.Text = "Form1"
            CType(Me.TestDbDataSet, System.ComponentModel.ISupportInitialize).EndInit()
            CType(Me.TxtDataBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
            CType(Me.TxtDataBindingNavigator, System.ComponentModel.ISupportInitialize).EndInit()
            Me.TxtDataBindingNavigator.ResumeLayout(False)
            Me.TxtDataBindingNavigator.PerformLayout()
            CType(Me.TxtDataDataGridView, System.ComponentModel.ISupportInitialize).EndInit()
            Me.ResumeLayout(False)
            Me.PerformLayout()
    
        End Sub
        Friend WithEvents TestDbDataSet As MyApp.TestDbDataSet
        Friend WithEvents TxtDataBindingSource As System.Windows.Forms.BindingSource
        Friend WithEvents TxtDataTableAdapter As MyApp.TestDbDataSetTableAdapters.TxtDataTableAdapter
        Friend WithEvents TableAdapterManager As MyApp.TestDbDataSetTableAdapters.TableAdapterManager
        Friend WithEvents TxtDataBindingNavigator As System.Windows.Forms.BindingNavigator
        Friend WithEvents BindingNavigatorAddNewItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents BindingNavigatorCountItem As System.Windows.Forms.ToolStripLabel
        Friend WithEvents BindingNavigatorDeleteItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents BindingNavigatorMoveFirstItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents BindingNavigatorMovePreviousItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents BindingNavigatorSeparator As System.Windows.Forms.ToolStripSeparator
        Friend WithEvents BindingNavigatorPositionItem As System.Windows.Forms.ToolStripTextBox
        Friend WithEvents BindingNavigatorSeparator1 As System.Windows.Forms.ToolStripSeparator
        Friend WithEvents BindingNavigatorMoveNextItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents BindingNavigatorMoveLastItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents BindingNavigatorSeparator2 As System.Windows.Forms.ToolStripSeparator
        Friend WithEvents TxtDataBindingNavigatorSaveItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents TxtDataDataGridView As System.Windows.Forms.DataGridView
        Friend WithEvents DataGridViewTextBoxColumn1 As System.Windows.Forms.DataGridViewTextBoxColumn
        Friend WithEvents DataGridViewTextBoxColumn2 As System.Windows.Forms.DataGridViewTextBoxColumn
        Friend WithEvents DataGridViewTextBoxColumn3 As System.Windows.Forms.DataGridViewTextBoxColumn
    
    End Class
    

    Friday, February 21, 2014 5:15 PM
  • Hi !

          Finally i solved my problem by checking various points. Since a simple project with a single form and dataset throws the exception, there is nothing wrong in the code. The connection string is also in right format and no error in path. There is no issue regarding naming the files. I have tried by unistalling and re-install .net framework 4.5 but it was not solved. Finally i unistalled and re-installed sql server compact 4.0 sp1 which solved my problem. Now new projects are working fine, ofcourse those projects created previously are still throwing same expression. I think there is a problem with SQL server compact 4.0 sp1 previously installed which may be corrupted. Thank you for attention and reply to my query.

    • Marked as answer by Marvin_Guo Friday, February 28, 2014 5:34 AM
    Wednesday, February 26, 2014 4:11 PM