Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2006-06-15
5
Medium Priority
?
16,632 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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

916 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