异常:'system.data.sqlclient.sqlconnection'的类型初始化程序? [英] Exception: type initializer for 'system.data.sqlclient.sqlconnection'?

查看:559
本文介绍了异常:'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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆