lee_ingram
asked on
The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception. vb.net gina SQL
Hi,
I have written my own custom gina, which then calls into a .net assembly(dll).
Within this assembly im trying to connect to a SQL database, but receive the following error:
The type initializer for 'System.Data.SqlClient.Sql Connection ' threw an exception.
It happens on the following line in my code:
_sqlCnn = New SqlConnection(connectionSt ring)
where connectionString is a valid connection string as i use the same one as a previous application that worked. Any idea? please note that im NOT logged in, so I believe the process is running under a SYSTEM account, the same as the windows logon app.
Full trace details are:
2006-06-15 13:46:05 ERR -1 ForgotPasswordService System.TypeInitializationE xception: The type initializer for 'System.Data.SqlClient.Sql Connection ' threw an exception. ---> System.TypeInitializationE xception: The type initializer for 'System.Data.SqlClient.Sql Connection Factory' threw an exception. ---> System.TypeInitializationE xception: The type initializer for 'System.Data.SqlClient.Sql Performanc eCounters' threw an exception. ---> System.Configuration.Confi gurationEr rorsExcept ion: Configuration system failed to initialize ---> System.ArgumentException: Illegal characters in path.
at System.Security.Permission s.FileIOPe rmission.H asIllegalC haracters( String[] str)
at System.Security.Permission s.FileIOPe rmission.A ddPathList (FileIOPer missionAcc ess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
at System.Security.Permission s.FileIOPe rmission.. ctor(FileI OPermissio nAccess access, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath)
at System.IO.Path.GetFullPath (String path)
at System.Configuration.Clien tConfigPat hs..ctor(S tring exePath, Boolean includeUserConfig)
at System.Configuration.Clien tConfigPat hs.GetPath s(String exePath, Boolean includeUserConfig)
at System.Configuration.Clien tConfigura tionHost.g et_ConfigP aths()
at System.Configuration.Clien tConfigura tionHost.G etStreamNa me(String configPath)
at System.Configuration.Clien tConfigura tionSystem ..ctor()
at System.Configuration.Confi gurationMa nager.Ensu reConfigur ationSyste m()
--- End of inner exception stack trace ---
at System.Configuration.Confi gurationMa nager.Ensu reConfigur ationSyste m()
at System.Configuration.Confi gurationMa nager.GetS ection(Str ing sectionName)
at System.Configuration.Privi legedConfi gurationMa nager.GetS ection(Str ing sectionName)
at System.Diagnostics.Diagnos ticsConfig uration.Ge tConfigSec tion()
at System.Diagnostics.Diagnos ticsConfig uration.In itialize()
at System.Diagnostics.Switch. Initialize ConfigSett ings()
at System.Diagnostics.Switch. Initialize WithStatus ()
at System.Diagnostics.Switch. get_Switch Setting()
at System.Diagnostics.TraceSw itch.get_L evel()
at System.Data.ProviderBase.D bConnectio nPoolCount ers..ctor( String categoryName, String categoryHelp)
at System.Data.SqlClient.SqlP erformance Counters.. ctor()
at System.Data.SqlClient.SqlP erformance Counters.. cctor()
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlC onnectionF actory..ct or()
at System.Data.SqlClient.SqlC onnectionF actory..cc tor()
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlC onnection. .cctor()
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlC onnection. .ctor()
at System.Data.SqlClient.SqlC onnection. .ctor(Stri ng connectionString)
at CustomIE.DatabaseLibrary.S toredProce dure..ctor (String spName, String connectionString)
I have written my own custom gina, which then calls into a .net assembly(dll).
Within this assembly im trying to connect to a SQL database, but receive the following error:
The type initializer for 'System.Data.SqlClient.Sql
It happens on the following line in my code:
_sqlCnn = New SqlConnection(connectionSt
where connectionString is a valid connection string as i use the same one as a previous application that worked. Any idea? please note that im NOT logged in, so I believe the process is running under a SYSTEM account, the same as the windows logon app.
Full trace details are:
2006-06-15 13:46:05 ERR -1 ForgotPasswordService System.TypeInitializationE
at System.Security.Permission
at System.Security.Permission
at System.Security.Permission
at System.IO.Path.GetFullPath
at System.Configuration.Clien
at System.Configuration.Clien
at System.Configuration.Clien
at System.Configuration.Clien
at System.Configuration.Clien
at System.Configuration.Confi
--- End of inner exception stack trace ---
at System.Configuration.Confi
at System.Configuration.Confi
at System.Configuration.Privi
at System.Diagnostics.Diagnos
at System.Diagnostics.Diagnos
at System.Diagnostics.Switch.
at System.Diagnostics.Switch.
at System.Diagnostics.Switch.
at System.Diagnostics.TraceSw
at System.Data.ProviderBase.D
at System.Data.SqlClient.SqlP
at System.Data.SqlClient.SqlP
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlC
at System.Data.SqlClient.SqlC
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlC
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlC
at System.Data.SqlClient.SqlC
at CustomIE.DatabaseLibrary.S
ASKER
The connection string works fine. Im not using any .config files within my application.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi,
I saw this article easier, and decide to write a C++ Database access class.
Thanks for looking for me and helping out.
Cheers
Lee
I saw this article easier, and decide to write a C++ Database access class.
Thanks for looking for me and helping out.
Cheers
Lee
This problem also occurs if the app.config file has been corrupted. For instance if you manually edited it, and there exists invalid section references.
It is probable, however, that there is an error in one of your .config files, since the system seems to be finding an illegal character within the System.Configuration tree.