服务取决于SQL Server [英] Service depends on SQL Server

查看:66
本文介绍了服务取决于SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Windows服务在启动时启动时遇到问题。

它需要SQL Server启动。我已将MSSQLSERVER添加到服务

依赖项中(如 http://中所述) tinyurl.com/5s7kx )但这并不是
帮助。我将依赖从MSSQLSERVER更改为SQLSERVERAGENT,其中
没有任何区别。我记录了事件日志的异常,它告诉我

跟随错误,删节:


用户''xxxxxx'登录失败。

在System.Data.SqlClient.ConnectionPool.GetConnection(布尔&

isInTransaction)

at

System.Data.SqlClient.SqlConnectionPoolManager .Get PooledConnection(SqlConnec

tionString选项,布尔& isInTransaction)

在System.Data.SqlClient.SqlConnection.Open()

< snip>


我想我需要在服务器中循环几次才能捕获此异常

启动时间长达SQL Server的时间完全旋转。

其他人有其他想法吗?该服务是用C#编写的。


- Alan

I have a Windows service that is having trouble starting up at boot time.
It requires SQL Server to start up. I have added MSSQLSERVER to the service
dependencies (as explained in http://tinyurl.com/5s7kx) but that doesn''t
help. I changed the dependency from MSSQLSERVER to SQLSERVERAGENT which
made no difference. I log exceptions to the eventlog which tell me the
following error, abridged:

Login failed for user ''xxxxxx''.
at System.Data.SqlClient.ConnectionPool.GetConnection (Boolean&
isInTransaction)
at
System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnec
tionString options, Boolean& isInTransaction)
at System.Data.SqlClient.SqlConnection.Open()
<snip>

I''m thinking I need to catch this exception in a loop a few times at service
startup for a long enough time for SQL Server to completely spin up.
Anybody else have other ideas? The service is written in C#.

-- Alan

推荐答案

尝试玩恢复选项卡参数。


您仍然希望您的服务依赖于MSSQLSERVER。如果我正确记得

,则SQLSERVERAGENT服务不会自动启动。

Dave

" Alan Pretre" <人******** @ newsgroup.nospam>在留言中写道

新闻:%2 **************** @ tk2msftngp13.phx.gbl ...
Try playing with the "Recovery" tab parameters.

You still want your service dependent on MSSQLSERVER. If I remember
correctly, the SQLSERVERAGENT service is not started Automatically.

Dave
"Alan Pretre" <al********@newsgroup.nospam> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
我有在启动时启动时出现问题的Windows服务。
它需要SQL Server启动。我已将MSSQLSERVER添加到
服务
依赖项中(如 http://中所述) tinyurl.com/5s7kx )但这并没有帮助。我将依赖从MSSQLSERVER更改为SQLSERVERAGENT,这没有任何区别。我记录了事件日志中的异常,告诉我
以下错误,删除:

用户''xxxxxx'登录失败。
在System.Data.SqlClient.ConnectionPool。 GetConnection(布尔&
isInTransaction)
System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnec
tionString选项,布尔& isInTransaction)
在System.Data .SqlClient.SqlConnection.Open()
< snip>

我想我需要在
服务中多次在循环中捕获此异常启动足够长的时间让SQL Server完全启动。
还有其他人有其他想法吗?该服务是用C#编写的。

- Alan
I have a Windows service that is having trouble starting up at boot time.
It requires SQL Server to start up. I have added MSSQLSERVER to the
service
dependencies (as explained in http://tinyurl.com/5s7kx) but that doesn''t
help. I changed the dependency from MSSQLSERVER to SQLSERVERAGENT which
made no difference. I log exceptions to the eventlog which tell me the
following error, abridged:

Login failed for user ''xxxxxx''.
at System.Data.SqlClient.ConnectionPool.GetConnection (Boolean&
isInTransaction)
at
System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnec
tionString options, Boolean& isInTransaction)
at System.Data.SqlClient.SqlConnection.Open()
<snip>

I''m thinking I need to catch this exception in a loop a few times at
service
startup for a long enough time for SQL Server to completely spin up.
Anybody else have other ideas? The service is written in C#.

-- Alan





您可以在代码中设置依赖项。下面的代码片段来自我写的

服务,它确保SQL Server在它开始之前运行。在我的服务上运行InstallUtil后,MSSQLSERVER列在服务窗口的

依赖于选项卡中。当我重新启动或从

命令行启动时,我没有任何问题。您不必编写任何重试循环代码

或在代码中执行任何特殊操作:


private void InitializeComponent()

{

....

//

//服务

//

this.service.ServicesDependedOn = new string [] {" MSSQLSERVER"};

this.service.DisplayName =" Xxxxx";

this.service .ServiceName =" Xxxxx";

this.service.StartType = System.ServiceProcess.ServiceStartMode.Automatic;

....

}


- 理查德


" Alan Pretre"写道:
Hi,

You can set the dependency in code. The code snippet below is from a
service that I wrote that assures that SQL Server is running before it
starts. After I run InstallUtil on my service MSSQLSERVER is listed in the
depended on tab in the services window. When I reboot or start from a
command line I have no problems. You should not have to code any retry loops
or take any special action in your code:

private void InitializeComponent()
{
....
//
// service
//
this.service.ServicesDependedOn = new string[] {"MSSQLSERVER"};
this.service.DisplayName = "Xxxxx";
this.service.ServiceName = "Xxxxx";
this.service.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
....
}

--Richard

"Alan Pretre" wrote:
我有一个Windows服务,在启动时启动时遇到问题。
它需要SQL Server启动。我已将MSSQLSERVER添加到服务
依赖项中(如 http://tinyurl.com/中所述) 5s7kx )但这并没有帮助。我将依赖从MSSQLSERVER更改为SQLSERVERAGENT,这没有任何区别。我记录了事件日志中的异常,告诉我
以下错误,删除:

用户''xxxxxx'登录失败。
在System.Data.SqlClient.ConnectionPool。 GetConnection(布尔&
isInTransaction)
System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnec
tionString选项,布尔& isInTransaction)
在System.Data .SqlClient.SqlConnection.Open()
< snip>

我想我需要在服务启动时多次在循环中捕获此异常SQL Server完全启动的时间足够长。
其他人有其他想法吗?该服务是用C#编写的。

- Alan
I have a Windows service that is having trouble starting up at boot time.
It requires SQL Server to start up. I have added MSSQLSERVER to the service
dependencies (as explained in http://tinyurl.com/5s7kx) but that doesn''t
help. I changed the dependency from MSSQLSERVER to SQLSERVERAGENT which
made no difference. I log exceptions to the eventlog which tell me the
following error, abridged:

Login failed for user ''xxxxxx''.
at System.Data.SqlClient.ConnectionPool.GetConnection (Boolean&
isInTransaction)
at
System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnec
tionString options, Boolean& isInTransaction)
at System.Data.SqlClient.SqlConnection.Open()
<snip>

I''m thinking I need to catch this exception in a loop a few times at service
startup for a long enough time for SQL Server to completely spin up.
Anybody else have other ideas? The service is written in C#.

-- Alan



我会先尝试理查德的解决方案做其他事情。


看起来它会起作用。


好​​理查德!

" Richard" <日***** @ discussions.microsoft.com>在消息中写道

新闻:49 ********************************** @ microsof t.com ...
I would try Richard''s solution before doing anything else.

This looks like it will work.

Nice Richard!
"Richard" <Ri*****@discussions.microsoft.com> wrote in message
news:49**********************************@microsof t.com...
您好,

您可以在代码中设置依赖关系。下面的代码片段来自我写的
服务,该服务确保SQL Server在它启动之前运行。在我的服务上运行InstallUtil后,MSSQLSERVER列在服务窗口中依赖于选项卡的
。当我重新启动或从
命令行启动时,我没有任何问题。您不必编写任何重试
循环
或在您的代码中采取任何特殊操作:

private void InitializeComponent()
{
.. ..
//
//服务
//
this.service.ServicesDependedOn = new string [] {" MSSQLSERVER"};
this.service。 DisplayName =" Xxxxx";
this.service.ServiceName =" Xxxxx";
this.service.StartType =
System.ServiceProcess.ServiceStartMode.Automatic;
.. ..
}
- 理查德

Alan Pretre写道:
Hi,

You can set the dependency in code. The code snippet below is from a
service that I wrote that assures that SQL Server is running before it
starts. After I run InstallUtil on my service MSSQLSERVER is listed in
the
depended on tab in the services window. When I reboot or start from a
command line I have no problems. You should not have to code any retry
loops
or take any special action in your code:

private void InitializeComponent()
{
....
//
// service
//
this.service.ServicesDependedOn = new string[] {"MSSQLSERVER"};
this.service.DisplayName = "Xxxxx";
this.service.ServiceName = "Xxxxx";
this.service.StartType =
System.ServiceProcess.ServiceStartMode.Automatic;
....
}

--Richard

"Alan Pretre" wrote:
我有一个Windows服务,在启动时启动时遇到问题。
它需要SQL Server启动。我已将MSSQLSERVER添加到
服务
依赖项中(如 http://中所述) tinyurl.com/5s7kx )但这并没有帮助。我将依赖从MSSQLSERVER更改为SQLSERVERAGENT,这没有任何区别。我记录了事件日志中的异常,告诉我
以下错误,删除:

用户''xxxxxx'登录失败。
在System.Data.SqlClient.ConnectionPool。 GetConnection(布尔&
isInTransaction)
System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnec
tionString选项,布尔& isInTransaction)
在System.Data .SqlClient.SqlConnection.Open()
< snip>

我想我需要在
服务中多次在循环中捕获此异常启动足够长的时间让SQL Server完全启动。
还有其他人有其他想法吗?该服务是用C#编写的。

- Alan
I have a Windows service that is having trouble starting up at boot time.
It requires SQL Server to start up. I have added MSSQLSERVER to the
service
dependencies (as explained in http://tinyurl.com/5s7kx) but that doesn''t
help. I changed the dependency from MSSQLSERVER to SQLSERVERAGENT which
made no difference. I log exceptions to the eventlog which tell me the
following error, abridged:

Login failed for user ''xxxxxx''.
at System.Data.SqlClient.ConnectionPool.GetConnection (Boolean&
isInTransaction)
at
System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnec
tionString options, Boolean& isInTransaction)
at System.Data.SqlClient.SqlConnection.Open()
<snip>

I''m thinking I need to catch this exception in a loop a few times at
service
startup for a long enough time for SQL Server to completely spin up.
Anybody else have other ideas? The service is written in C#.

-- Alan



这篇关于服务取决于SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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