异常:'system.data.sqlclient.sqlconnection'的类型初始化程序? [英] Exception: type initializer for 'system.data.sqlclient.sqlconnection'?
问题描述
System.Data.SqlClient.SqlConnection的类型初始化程序抛出异常
首次尝试:我正在使用WCF服务来制作一些小应用程序。它工作正常,我可以正确使用LINQ。 2或3天后。也许在我关闭Visual studio并重新加载该项目之后。出现异常。
第二次尝试也一样。我创建另一个项目,它工作正常,直到我做别的事情(我不更改任何代码)
SQL Server工作正常,我可以通过SQL Management Studio连接,没有问题。
点击Debug错误会导致linq文件中的连接字符串。
什么可以问题?我试图搜索,但找不到解决这个问题的答案。
谢谢
这很可能意味着你的app.config文件有一个错误,例如格式不正确的XML或意外的元素。发生错误是因为SqlConnection中的静态字段从app.config读取以确定跟踪详细级别,如下所述: http://msdn.microsoft.com/en-us/library/ms254503.aspx
I couldn't figure out what is the problem for this exception.
The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception
First attempt: I was using the WCF Service to make some small application. It works just fine and I can use the LINQ properly. After 2 or 3 days. Maybe after I close Visual studio and load the project again. The exception appear.
The 2nd attempt also the same. I create another project and it work just fine until I do something else (I do not change any code)
SQL Server working fine and I can connect through SQL Management Studio without problem.
A click at Debug error lead me to the connection string from linq file.
What could be the problem? I tried to search but couldn't find the answer to resolve this.
Thank you
This most likely means that there is an error in your app.config file, e.g. badly formed XML or unexpected elements. 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
这篇关于异常:'system.data.sqlclient.sqlconnection'的类型初始化程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!