1
我在Windows家庭高級版ISS服務器上運行C#CGI應用程序時出現問題。 我的代碼如下:CGI應用程序與SQL LINQ錯誤
Console.Write("Content-Type: text/plain\n\n");
string conn = "Data Source=|C:\\DB|\\RegisteredUsers.sdf";
Console.WriteLine(conn); // Added for debugging
RegisteredUsers userdb = new RegisteredUsers(conn); //DBML file from SqlMetal Here
我得到的錯誤是:
Data Source=RegisteredUsers.sdf
Unhandled Exception: System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.ArgumentException: Illegal characters in path.
at System.Security.Permissions.FileIOPermission.HasIllegalCharacters(String[] str)
at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path)
at System.AppDomainSetup.VerifyDir(String dir, Boolean normalize)
at System.AppDomainSetup.get_ConfigurationFile()
at System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig)
at System.Configuration.ClientConfigPaths.GetPaths(String exePath, Boolean includeUserConfig)
at System.Configuration.ClientConfigurationHost.GetStreamName(String configPath)
at System.Configuration.ClientConfigurationHost.get_IsAppConfigHttp()
at System.Configuration.ClientConfigurationSystem..ctor()
at System.Configuration.ConfigurationManager.EnsureConfigurationSystem()
--- End of inner exception stack trace ---
at System.Configuration.ConfigurationManager.EnsureConfigurationSystem()
at System.Configuration.ConfigurationManager.PrepareConfigSystem()
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
at System.Data.Common.DbProviderFactories.Initialize()
at System.Data.Common.DbProviderFactories.GetFactoryClasses()
at System.Data.Linq.SqlClient.SqlProvider.GetProvider(String providerName)
at Syst em.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Initialize(IData Services dataServices, Object connection)
at System.Data.Linq.DataContext.Init(Object connection, MappingSource mapping)
at System.Data.Linq.DataContext..ctor(String fileOrServerOrConnection, M appingSource mapping)
at Validate.Program.Main(String[] args)
似乎錯誤或者是字符串conn = @"Data Source=RegisteredUsers.sdf";
或 RegisteredUsers userdb = new RegisteredUsers(conn);
,我沒有理由相信該字符串定義是壞的所以我認爲它是在 RegisteredUsers userdb = new RegisteredUsers(conn);
仍然不起作用。同樣的錯誤。 該行現在是: string conn =「Data Source = RegisteredUsers.sdf」; 我剛纔提到這個工程很好,如果我只是從CMD啓動EXE? – DrAwesome
你好,沒有你沒有提到,但你也試過這個呢? string conn =「Data Source = | DataDirectory | \\ RegisteredUsers.sdf」; –
是的,我試過,無濟於事。 – DrAwesome