在Exception上需要帮助“System.Transactions.Diagnostics.DiagnosticTrace的类型初始化程序”引发了异常“ [英] need help on Exception "The type initializer for 'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception"

查看:58
本文介绍了在Exception上需要帮助“System.Transactions.Diagnostics.DiagnosticTrace的类型初始化程序”引发了异常“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


Hi,

我有一个函数来获取ole数据库中表的列属性。奇怪的是该程序在VS2008中成功运行,但是在我构建并在Windows中运行它之后,它给了我异常"System.Transactions.Diagnostics.DiagnosticTrace的类型初始化器"引发了异常"。我在互联网上查找了这个异常,他们建议删除app.config和重建应用程序,但是我没有为这个程序创建app.config。所以我输了..

I  have a function to obtain column properties of a table in ole database. Strange thing is that the program ran successfully within VS2008,  but after I built and run it in windows, it gives me exception "The type initializer for 'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception".  I looked for this exception in internet, and they suggest delete app.config and rebuilt application, but I didn't create a app.config for this program. So I lost..

任何人都可以帮忙吗?以下是我的代码。

Can anyone help?  Following is my code.




代码片段

推荐答案

异常的堆栈跟踪内部是什么。很可能您没有访问系统表的权限,并且您获得了安全性异常。另一方面,如果您使用系统表,我会假设您正在使用SQL Server。在这种情况下,
最好使用本机SQL Server提供程序(System.Data.SqlClient namesapce)并使用SqlConnection的GetSchema方法获取有关对象的信息

 

What is inside of stack trace of your exception. Quite possible you do not have permissions to access system tables and you get security exception. On other side, if you are using system tables I would assume you are working with SQL Server. In this case it is better to use native SQL Server provider (System.Data.SqlClient namesapce) and get information about objects using GetSchema method of SqlConnection

 

http://www.xporttools.net


这篇关于在Exception上需要帮助“System.Transactions.Diagnostics.DiagnosticTrace的类型初始化程序”引发了异常“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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