DataContext.CreateDatabase causes error "Illegal characters in path"

Unanswered DataContext.CreateDatabase causes error "Illegal characters in path"

  • Friday, June 27, 2008 4:19 PM
     
     
    I'm using the version of SQL Server that comes w/ VS2008, adding a database (.mdf) file to my App_Data folder.

    That database w/ a single table - 'Customers'. There are only about 3 columns in said table:

    ID - uniqueidentifier
    FirstName - nvarchar(50)
    LastName - nvarchar(50)

    I used the LINQtoSQL designer to generate my DataContext class. I then removed the Customers table from the db.

    I then called CreateDatabase from my DataContext class and every time, it errs with the following info:

     Illegal characters in path.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Exception Details: System.ArgumentException: Illegal characters in path.

    Source Error:

    Line 21:     {
    Line 22:         DataClassesDataContext dc = new DataClassesDataContext();
    Line 23:         dc.CreateDatabase();
    Line 24:     }
    Line 25: }


    Source File: c:\inetpub\wwwroot\WebSite\Default.aspx.cs    Line: 23

    Stack Trace:

    [ArgumentException: Illegal characters in path.]
       System.IO.Path.CheckInvalidPathChars(String path) +2913282
       System.IO.Path.NormalizePathFast(String path, Boolean fullCheck) +106
       System.IO.Path.GetFullPathInternal(String path) +45
       System.IO.Path.GetFullPath(String path) +33
       System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.CreateDatabase() +1115
       System.Data.Linq.DataContext.CreateDatabase() +82
       _Default.btn_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\WebSite\Default.aspx.cs:23
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    I've tried this with 2 different databases and cannot figure out what "path" has illegal characters in it. Any idea why this is happening?

    Thanks.

All Replies

  • Friday, June 27, 2008 8:25 PM
     
     
    Hi,

     This may be a misleading exception; it can be it is related to security instead. Does the user that runs the web application has write access to the folder you are trying to create the database in?

     --larsw
  • Friday, June 27, 2008 9:53 PM
     
     

    For the sake of testing, I gave EVERYONE full access to the root of the site - same error.

  • Tuesday, August 19, 2008 12:45 AM
     
     

    I'm getting the same error in a console application running with administrator privileges.

     

    Both when trying to create a local mdf file and when trying to create the database on the server (local).