简体   繁体   English

System.Data.SqlClient的类型初始值设定项引发了异常

[英]type initializer for System.Data.SqlClient threw an exception

This actually worked before but now, not. 这实际上在以前但现在没有奏效。

string sqlConnString ="Server=server1;Database=Production;Trusted_Connection=true;User ID=User;Password=pwd"; 

        try {
            conn = new SqlConnection(sqlConnString );

And I get the exception. 我得到了例外。 (I know the connection string should be in app.config but that didn't work, either.) (我知道连接字符串应该在app.config中,但这也不起作用。)

This most likely means that there is an error in your app.config file, eg badly formed XML or unexpected elements. 这很可能意味着您的app.config文件中存在错误,例如XML格式错误或意外的元素。 The error happens because the static fields inside SqlConnection read from app.config to determine trace detail level as described here: http://msdn.microsoft.com/en-us/library/ms254503.aspx 发生错误是因为SqlConnection内的静态字段从app.config中读取,以确定跟踪详细信息级别,如下所述: http : //msdn.microsoft.com/zh-cn/library/ms254503.aspx

(this question is a duplicate of Exception: type initializer for 'system.data.sqlclient.sqlconnection'? ) (这个问题是Exception的重复:'system.data.sqlclient.sqlconnection'的类型初始化器?

删除可信和连接之间的下划线。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 netcore3.1 System.Data.SqlClient 上的 Azure 函数 3.0.1:“System.Data.SqlClient.TdsParser”的类型初始值设定项引发异常 - Azure Function 3.0.1 on netcore3.1 System.Data.SqlClient: The type initializer for 'System.Data.SqlClient.TdsParser' threw an exception 'System.Data.SqlClient.SqlConnection'的类型初始值设定项引发异常.Windows Server 2016 - The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception.Windows server 2016 “Microsoft.Data.SqlClient.SNINativeMethodWrapper”的类型初始值设定项引发异常 - The type initializer for 'Microsoft.Data.SqlClient.SNINativeMethodWrapper' threw an exception 'System.Data.SqlClient.TdsParser' 的类型初始值设定项在从 Azure function 调用存储过程时抛出异常错误 - The type initializer for 'System.Data.SqlClient.TdsParser' threw an exception error while calling Stored Procedure from Azure function 设置'引发了'System.Data.SqlClient.SqlException'类型的异常 - Settings' threw an exception of type 'System.Data.SqlClient.SqlException' 例外:“system.data.sqlclient.sqlconnection”的类型初始值设定项? - Exception: type initializer for 'system.data.sqlclient.sqlconnection'? System.Data.Entity.MigrateDatabaseToLatestVersion 的类型初始值设定项引发异常 - The type initializer for System.Data.Entity.MigrateDatabaseToLatestVersion threw an exception 'System.Data.Entity.Migrations.DbMigrationsConfiguration`1' 的类型初始值设定项抛出异常 - The type initializer for 'System.Data.Entity.Migrations.DbMigrationsConfiguration`1' threw an exception Windows CE(System.Data.SQLClient)上的异常'SqlException' - Exception 'SqlException' on Windows CE (System.Data.SQLClient) 在命名空间“System.Data.SqlClient”中找不到类型名称“SqlConnection” - The type name 'SqlConnection' could not be found in the namespace 'System.Data.SqlClient'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM