I Will Explain what i am exactly doing.
(.Net application)
STEP 1:
I Have taken the one class library file in which i have added the WCF service. In this service i am peforming operations.
STEP 2:
I have added the windows service in the same solution. In this service i have hosted the WCF service and debug it.
So it is working fine.
STEP 3:
Then I had created the set up of that files using installshied(basic msi project) and i install it. It is working fine.
But I am trying to install it using InstallUtil.exe it is giving error.
Error Message:
Installing assembly 'C:\Users\Dattaprasad\Desktop\TestAllBrowswer\WindowsService1.exe'.
Affected parameters are:
i =
logtoconsole =
logfile = C:\Users\Dattaprasad\Desktop\TestAllBrowswer\WindowsService1.InstallLog
assemblypath = C:\Users\Dattaprasad\Desktop\TestAllBrowswer\WindowsService1.exe
name = HostCompression
Installing service HostCompression...
Service HostCompression has been successfully installed.
Creating EventLog source HostCompression in log Application...
An exception occurred in the OnAfterInstall event handler of System.ServiceProcess.ServiceInstaller.
System.InvalidOperationException: Cannot start service HostCompression on computer '.'.
The inner exception System.ComponentModel.Win32Exception was thrown with the following error message:
The service did not respond to the start or control request in a timely fashion.
Rolling back assembly 'C:\Users\Dattaprasad\Desktop\TestAllBrowswer\WindowsService1.exe'.
Affected parameters are:
i =
logtoconsole =
logfile = C:\Users\Dattaprasad\Desktop\TestAllBrowswer\WindowsService1.InstallLog
assemblypath = C:\Users\Dattaprasad\Desktop\TestAllBrowswer\WindowsService1.exe
name = HostCompression
Restoring event log to previous state for source HostCompression.
Service HostCompression is being removed from the system...
Service HostCompression was successfully removed from the system.
What I have tried:
Service1.cs file:-
ServiceHost m_serviceHost;
public Service1()
{
InitializeComponent();
}
public void OnDebug()
{
OnStart(null);
}
protected override void OnStart(string[] args)
{
if (m_serviceHost != null) m_serviceHost.Close();
string strAdrTCP = "net.tcp://localhost:9200/CompressService";
string strAdrWebHttp = "http://localhost:9100/CompressService";
Uri[] adrbase = {
new Uri(strAdrTCP),
new Uri(strAdrWebHttp)
};
m_serviceHost = new ServiceHost(typeof(TestAllBrowser.Test), adrbase);
ServiceMetadataBehavior mBehave = new ServiceMetadataBehavior();
m_serviceHost.Description.Behaviors.Add(mBehave);
#region BasicHttpBinding
#endregion
#region NetTcpBinding
NetTcpBinding tcpb = new NetTcpBinding();
tcpb.MaxReceivedMessageSize = 2147483647;
tcpb.MaxBufferPoolSize = 2147483647;
tcpb.MaxBufferSize = 2147483647;
tcpb.TransferMode = TransferMode.Streamed;
tcpb.ReceiveTimeout = new TimeSpan(0, 10, 00);
tcpb.SendTimeout = new TimeSpan(0, 10, 00);
tcpb.CloseTimeout = new TimeSpan(0, 10, 00);
m_serviceHost.AddServiceEndpoint(typeof(TestAllBrowser.ITest), tcpb, strAdrTCP);
m_serviceHost.AddServiceEndpoint(typeof(IMetadataExchange),
MetadataExchangeBindings.CreateMexTcpBinding(), "mex");
#endregion
#region WebHttpBinding
WebHttpBinding webb = new WebHttpBinding();
webb.MaxReceivedMessageSize = 2147483647;
webb.MaxBufferPoolSize = 2147483647;
webb.MaxBufferSize = 2147483647;
webb.TransferMode = TransferMode.Streamed;
webb.ReceiveTimeout = new TimeSpan(0, 10, 00);
webb.SendTimeout = new TimeSpan(0, 10, 00);
webb.CloseTimeout = new TimeSpan(0, 10, 00);
webb.CrossDomainScriptAccessEnabled = true;
m_serviceHost.AddServiceEndpoint(typeof(TestAllBrowser.ITest), webb, strAdrWebHttp).Behaviors.Add((IEndpointBehavior)new WebHttpBehavior());
m_serviceHost.AddServiceEndpoint(typeof(IMetadataExchange),
MetadataExchangeBindings.CreateMexHttpBinding(), "mex");
#endregion
m_serviceHost.Open();
}
protected override void OnStop()
{
if (m_serviceHost != null)
m_serviceHost.Close();
m_serviceHost = null;
}
ProjectInstaller.cs class
[RunInstaller(true)]
public partial class ProjectInstaller : System.Configuration.Install.Installer
{
private IContainer components = (IContainer)null;
private ServiceProcessInstaller process;
private ServiceInstaller service;
private ServiceProcessInstaller serviceProcessInstaller1;
private ServiceInstaller serviceInstaller1;
public ProjectInstaller()
{
this.process = new ServiceProcessInstaller();
this.process.Account = ServiceAccount.LocalSystem;
this.service = new ServiceInstaller();
this.service.ServiceName = "HostCompression";
this.service.DisplayName = "HostCompression";
this.service.Description = "WCF Service Hosted";
this.service.StartType = ServiceStartMode.Automatic;
this.Installers.Add((Installer)this.process);
this.Installers.Add((Installer)this.service);
this.service.AfterInstall += new InstallEventHandler(this.serviceInstaller1_AfterInstall);
}
private void serviceInstaller1_AfterInstall(object sender, InstallEventArgs e)
{
new ServiceController("HostCompression").Start();
}
private void InitializeComponent()
{
this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
this.serviceProcessInstaller1.Password = null;
this.serviceProcessInstaller1.Username = null;
this.serviceInstaller1.ServiceName = "Service1";
this.serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1,
this.serviceInstaller1});
}