I am getting an initialization exception when I instantiate SQLConnection.
The exception occurs emediately upon creating an instance and does not depend on whether I supply a connection string for the constructor.
The odd thing is that I am not getting this error on my development computer, only when I install it on a different computer. The computer giving the exception has .Net 2.0 installed from the redistributable which I downloaded from MS on Thursday.
This is happening before I set any properties or do anything else with the new connection.
Any ideas
Jake Wagner

can not create an SQLConnection object
curtisMcmillin
mihai.manole77
none of the config files mentioned seem to have any illegal characters and all of those files should be the defaults as we havn't customized anything.
The only connection string I could find in any of the config files mentioned is in machine.config and was this:
"data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient"I am not entierly sure what characters are legal in a connection string but I am fairly sure I have sucessfully used all of the characters in this except the bar "|".
Jacob Wagner
Sr. IT Tech.
American River College
Ajey
The exception says:
System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.ArgumentException: Illegal characters in path.
Have you checked that your production machine web.config, app.config or machine.config connectionstrings element does'nt contain any form of illegal characters
Bart from SLC
Ok it took a while to get this because of the situation when it occurs (see previous message). But here is the full text of the exception message:
************** Exception Text **************
System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnectionFactory' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlPerformanceCounters' threw an 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[] pathList, Boolean checkForDuplicates, Boolean needFullPath)
at System.IO.Path.GetFullPath(String path)
at System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig)
at System.Configuration.ClientConfigPaths.GetPaths(String exePath, Boolean includeUserConfig)
at System.Configuration.ClientConfigurationHost.get_ConfigPaths()
at System.Configuration.ClientConfigurationHost.GetStreamName(String configPath)
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.GetSection(String sectionName)
at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
at System.Diagnostics.DiagnosticsConfiguration.Initialize()
at System.Diagnostics.Switch.InitializeConfigSettings()
at System.Diagnostics.Switch.InitializeWithStatus()
at System.Diagnostics.Switch.get_SwitchSetting()
at System.Diagnostics.TraceSwitch.get_Level()
at System.Data.ProviderBase.DbConnectionPoolCounters..ctor(String categoryName, String categoryHelp)
at System.Data.SqlClient.SqlPerformanceCounters..ctor()
at System.Data.SqlClient.SqlPerformanceCounters..cctor()
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlConnectionFactory..ctor()
at System.Data.SqlClient.SqlConnectionFactory..cctor()
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlConnection..cctor()
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlConnection..ctor()
at HS1000.CSIT_Lab_LoginsDataSetTableAdapters.LoginsTableAdapter.InitConnection()
at HS1000.CSIT_Lab_LoginsDataSetTableAdapters.LoginsTableAdapter.get_Connection()
at HS1000.CSIT_Lab_LoginsDataSetTableAdapters.LoginsTableAdapter.InitAdapter()
at HS1000.CSIT_Lab_LoginsDataSetTableAdapters.LoginsTableAdapter.get_Adapter()
at HS1000.CSIT_Lab_LoginsDataSetTableAdapters.LoginsTableAdapter.Fill(LoginsDataTable dataTable)
at HS1000.frmNewUser2.NewUser_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINNT/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
CSITAuthPlug
Assembly Version: 0.0.0.0
Win32 Version:
CodeBase: file:///c:/Program%20Files/ARC/CSIT/CSITAuthPlug.dll
----------------------------------------
msvcm80
Assembly Version: 8.0.50608.0
Win32 Version: 8.00.50727.42
CodeBase: file:///C:/WINNT/WinSxS/x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd/msvcm80.dll
----------------------------------------
CSITauthPlug_Net
Assembly Version: 0.6.2271.41350
Win32 Version: 0.6.2271.41350
CodeBase: file:///C:/WINNT/system32/CSITauthPlug_Net.DLL
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINNT/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINNT/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
HS1000
Assembly Version: 0.6.2271.41349
Win32 Version: 0.6.2271.41349
CodeBase: file:///C:/WINNT/system32/HS1000.DLL
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINNT/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINNT/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Data
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINNT/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINNT/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
Accessibility
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINNT/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINNT/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
James K. Howey - MSFT
Roland Boon
Ok, there was no app.config file for the assembly that is having the problem (it is a DLL) so I deleted all config files in my solution and rebuilt it.
Then I uninstalled from my testing machine, deleted all remaining directories (just to make sure) and installed the program from scratch.
Then I tested the dll using a test program with the computer logged in and it worked properly.
Finally I restarted the system and attempted to run the dlls the way that they will be used in production (as part of the GINA) and I got the same "Illegal Characters in Path" error message when it attempted to make a connection over the network.
Could it be looking for the user's settings directory if so that might explain why when it is running as "System" it fails. I don't explicitly use the settigs directory but maybe either the SQL client or network client does.
Any thoughts
Seth Demsey
KarimRadi
The OS is Wibn XP w/P2. It has all the updates up to the date this thread started.
I tried reinstalling .Net 2.0 but got the same result.
I did discover one more thing that may be helpfull. But this is gona requier a little background:
My projects involves writing a plugin for a GINA called pGina < http://pgina.xpasystems.com/ >. I originaly wrote the plugin using .Net 1.1 and I am now in the process of upgrading to .Net 2.0
What I have discovered is that a new SQLConnection fails when created in the plugin (i.e. before a user is signed in) but works properly once the system is logged in.
Is there possibly something initialised at signin that I need to initialise before I can use an SQLConnection
This scheme was working in .Net 1.1 so my thought is that it should be possible in 2.0
Any thoughts
Joe Cotugno
Don't change that one, it's the default connectionstring for .NET so that one should be fine. BTW its looking like that on my machine too, and I don't have the problem.
Have you tried reinstalling the framework by running aspnet_regiis -i it's located under C:\Windows\Microsoft.NET\Framework\v2.0.50727
truelove84
The Exception does give a stack trace. I will some details later tonight (am an not near the computer at the moment).
The full Error message is quite long (because of the stack trace). The type is ItemInitializationException. If I recall correctly, the innermost exception is of type InvalidOperationException.
microman171
Steve J Wright
See the error details u have provided check this line
System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.ArgumentException: Illegal characters in path.
Check your solution. Delete the App.config file then rebuild your solution.
PaulDevine
I don't see AppSettings in anything I have posted, where are you getting that from
Where should I look for this setting I don't have any customized configuration files.
Jacob
AngRudy
XML files (and hence configuration files) are case-sensitive. Try changing the element's name from <AppSettings></AppSetings> to <appSettings></appSettings>.