Solved

The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception. vb.net gina SQL

Posted on 2006-06-15
5
16,206 Views
Last Modified: 2012-05-05
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.SqlConnection' threw an exception.

It happens on the following line in my code:

 _sqlCnn = New SqlConnection(connectionString)

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.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 System.Data.SqlClient.SqlConnection..ctor(String connectionString)
                                           at CustomIE.DatabaseLibrary.StoredProcedure..ctor(String spName, String connectionString)
0
Comment
Question by:lee_ingram
  • 2
  • 2
5 Comments
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 16912352
You should be VERY sure of that connection string....use a debugger, and dump it out BEFORE it is used in the constructor.

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.
0
 
LVL 1

Author Comment

by:lee_ingram
ID: 16918261
The connection string works fine.  Im not using any .config files within my application.
0
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 500 total points
ID: 16919473
0
 
LVL 1

Author Comment

by:lee_ingram
ID: 16920031
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
0
 
LVL 1

Expert Comment

by:fagdata
ID: 21002278
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.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question