windows服务开启不了提示错误1053 服务未及时响应启动或控制请求

kongling12 2012-10-22 10:11:41
小弟刚得到这个代码 但是 不能部署 用installutil安装成功 但是不能启动 谢谢! 上代码:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceModel;
using System.ServiceProcess;
using System.Text;
using Flexware.Data.Service.XDB;

namespace Flexware.WindowsService.Data
{
partial class DataService : ServiceBase
{
private ServiceHost m_XDBServiceHost;
private ServiceHost m_DataSchemeServiceHost;

public DataService()
{
InitializeComponent();
}

protected override void OnStart(string[] args)
{
m_XDBServiceHost = new ServiceHost(typeof(XDBService));
m_DataSchemeServiceHost = new ServiceHost(typeof(DataSchemeService));

m_XDBServiceHost.Open();
m_DataSchemeServiceHost.Open();
}

protected override void OnStop()
{
closeServiceHost();
}

private void closeServiceHost()
{
if (m_XDBServiceHost != null)
{
m_XDBServiceHost.Close();
}
if (m_DataSchemeServiceHost != null)
{
m_DataSchemeServiceHost.Close();
}
}
}
}






namespace Flexware.WindowsService.Data
{
partial class DataServiceInstaller
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Component Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.DataServiceProcessInstaller = new System.ServiceProcess.ServiceProcessInstaller();
this.XDBServiceInstaller = new System.ServiceProcess.ServiceInstaller();
//
// serviceProcessInstaller1
//
this.DataServiceProcessInstaller.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
this.DataServiceProcessInstaller.Password = null;
this.DataServiceProcessInstaller.Username = null;
//
// serviceInstaller1
//
this.XDBServiceInstaller.ServiceName = "XDBService";
this.XDBServiceInstaller.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
//
// ProjectInstaller
//
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.DataServiceProcessInstaller,
this.XDBServiceInstaller});

}

#endregion

private System.ServiceProcess.ServiceProcessInstaller DataServiceProcessInstaller;
private System.ServiceProcess.ServiceInstaller XDBServiceInstaller;
}
}



using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;

namespace Flexware.WindowsService.Data
{
[RunInstaller(true)]
public partial class DataServiceInstaller : System.Configuration.Install.Installer
{
public DataServiceInstaller()
{
InitializeComponent();
}
}
}



using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;

namespace Flexware.WindowsService.Data
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new DataService()
};
ServiceBase.Run(ServicesToRun);
}
}
}





<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="XmlFileDirectory" value="D:\\服务端文件\\XML"/>
<add key="RootXmlFileName" value="admin.xml"/> //这个不知道在那
</appSettings>

<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="SampleBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Flexware.Data.Service.XDB.XDBService" behaviorConfiguration="SampleBehavior">
<endpoint address="" binding="basicHttpBinding" contract="Flexware.Data.Service.XDB.IXDBService"/>

<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
<host>
<baseAddresses>
<add baseAddress="http://192.168.4.223:800/XDBService"/>
</baseAddresses>
</host>
</service>

<service name="Flexware.Data.Service.XDB.DataSchemeService" behaviorConfiguration="SampleBehavior">
<endpoint address="" binding="basicHttpBinding" contract="Flexware.Data.Service.XDB.IDataSchemeService"/>

<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
<host>
<baseAddresses>
<add baseAddress="http://192.168.4.223:800/DataSchemeService"/>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<customBinding>
<binding closeTimeout="00:30:00" openTimeout="00:30:00" receiveTimeout="00:30:00" sendTimeout="00:30:00">
<binaryMessageEncoding>
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
</binaryMessageEncoding>
<tcpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
</binding>
</customBinding>
<basicHttpBinding>
<binding name="NoneSecurity">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="NoneSecurity1" maxBufferPoolSize="12000000" maxReceivedMessageSize="12000000" useDefaultWebProxy="false">
<readerQuotas maxStringContentLength="12000000" maxArrayLength="12000000"/>

<security mode="None"/>
</binding>
</wsHttpBinding>
</bindings>



</system.serviceModel>


<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
</configuration>


...全文
701 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧