错误:Windows服务中的SqlConnection失败 [英] Error: Sqlconnection failed in windows service

查看:70
本文介绍了错误:Windows服务中的SqlConnection失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从窗口服务应用程序中收到此错误

I got this error from my window service application

the type initializer for System.Data.SqlClient.SqlConnection threw an exception.



以下是代码:



The following is the code:

Sqlconnection objconn = new SqlConnection("Data Source=Server1;Initial Catalog=Personel;Integrated Security=True");


我没有使用app.config.我尝试了另一种方法,但仍然失败.

关于


I am not using the app.config. I tried a different way but still failed.

Regards

推荐答案

我意识到您说过您不在使用app.config,但请尝试以下操作:

如果您的app.config包含"CustomConfiguration"部分,则将其注释掉.
I realize you stated that you''re not using the app.config, but try this:

If your app.config has a CustomConfiguration section, comment it out.


Internet上有很多讨论该主题的od线程.现在看看这两个:
SqlConnection类(.NET 2.0)中的更改 [ ^ ]
详细讨论了类似的问题 [ ^ ]

可能是因为您的app.config中有一些不需要的标签,或者您的machine.config可能已损坏.深入研究内部异常肯定会有所帮助.
There are lots od threads on internet discussing he same. Have a look at these two for now:
Changes in the SqlConnection class (.NET 2.0) [^]
Similar issue discussed at length[^]

It might be because of some unwanted tag in your app.config or your machine.config might have got corrupted. Looking deeper into the inner exception would surely help.


感谢您的输入.我删除了app.config,因为它已损坏.当我尝试查看配置的属性时,它给了我一条错误消息.
我添加了一个新值,添加了我的值,将其部署到生产服务器,然后就可以使用了.

感谢您的输入.
:laugh:
Thanks for the input. I deleted the app.config becuase it was corrupt. When I tried to view the properties of the config it gave me an error message.
I added a new one, add my values, deploy to production server, then it works.

Thanks for input.
:laugh:


这篇关于错误:Windows服务中的SqlConnection失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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