rybolt
Posts: 8
Joined: Fri Jul 30, 2010 9:07 pm

HELP: Creating installer with basic .net windows service

Hi all,

I am trying to create an installer with a very simple .net windows service, which acts as a host to a WCF service ( i.e. self-hosting).

The trivial example and entire code is here: http://msdn.microsoft.com/en-us/library/ms733069.aspx

I am using Custom Action to execute a .NET dll with the [RunInstaller(true)] attribute as described here: http://www.advancedinstaller.com/user-g ... #section37

When running with the .NET util app: InstallUtil it works fine, but when I use Adv. Installer Custom Action it just fails on the install, saying there was a problem with .NET Dll. It is in the "Install" group for Custom actions and left defaults as they seemed correct.

Any help appreciated, or if more info is needed let me know.

I did want to paste installer log here, that I think is relevant:

Code: Select all

MSI (s) (C8:14) [18:08:38:070]: Executing op: ActionStart(Name=dotNetCustAct.dll,,)
Action 18:08:38: dotNetCustAct.dll. 
MSI (s) (C8:14) [18:08:38:085]: Executing op: CustomActionSchedule(Action=dotNetCustAct.dll,ActionType=3073,Source=BinaryData,Target=InstallDotNetService,CustomActionData=/LogFile="C:\Program Files\Acme\Acme Test WCF Service\\InstallerLogFile.txt" /ReqVersion=2.0.50727 /InstallType=notransaction /Action=Install "C:\Program Files\Acme\Acme Test WCF Service\WCFService.exe" "C:\DOCUME~1\johndoe\LOCALS~1\Temp\dotNetCustAct.dll_Config.xml")
MSI (s) (C8:80) [18:08:38:101]: Invoking remote custom action. DLL: C:\WINDOWS\Installer\MSIAD.tmp, Entrypoint: InstallDotNetService
MSI (s) (C8:E8) [18:08:38:101]: Generating random cookie.
MSI (s) (C8:E8) [18:08:38:101]: Created Custom Action Server with PID 5520 (0x1590).
MSI (s) (C8:98) [18:08:38:132]: Running as a service.
MSI (s) (C8:98) [18:08:38:148]: Hello, I'm your 32bit Elevated custom action server.
MSI (s) (C8:14) [18:08:38:163]: Note: 1: 1723 2: dotNetCustAct.dll 3: InstallDotNetService 4: C:\WINDOWS\Installer\MSIAD.tmp 
Error 1723. There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor.  Action dotNetCustAct.dll, entry: InstallDotNetService, library: C:\WINDOWS\Installer\MSIAD.tmp 
MSI (s) (C8:14) [18:10:46:288]: Product: Acme Test WCF Service -- Error 1723. There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor.  Action dotNetCustAct.dll, entry: InstallDotNetService, library: C:\WINDOWS\Installer\MSIAD.tmp 

Action ended 18:10:46: InstallExecute. Return value 3.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: HELP: Creating installer with basic .net windows service

Hi,

Is the .NET DLL written as an installer class action? You can find more details about this here. If it is, are you overriding the "Install" method?

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rybolt
Posts: 8
Joined: Fri Jul 30, 2010 9:07 pm

Re: HELP: Creating installer with basic .net windows service

cosmin wrote: Is the .NET DLL written as an installer class action?
Yes it is.
cosmin wrote: If it is, are you overriding the "Install" method?
Yes I am. Let me post all my code so you can test it on your end.

I can't understand why, if in Adv. Installer, under 'Resources->Services' I install the following service, it works, but as a Custom .NET Dll installer class action, it does NOT work?

I appreciate your help, as I am evaluating your tool for possible purchase.

Code: Select all


using System.ComponentModel;
using System.Configuration.Install;
using System.ServiceModel;
using System.ServiceProcess;

namespace Microsoft.ServiceModel.Samples
{
    // Define a service contract.
    [ServiceContract(Namespace = "http://Microsoft.ServiceModel.Samples")]
    public interface ICalculator
    {
        [OperationContract]
        double Add(double n1, double n2);
        [OperationContract]
        double Subtract(double n1, double n2);
        [OperationContract]
        double Multiply(double n1, double n2);
        [OperationContract]
        double Divide(double n1, double n2);
    }

    // Implement the ICalculator service contract in a service class.
    public class CalculatorService : ICalculator
    {
        // Implement the ICalculator methods.
        public double Add(double n1, double n2)
        {
            double result = n1 + n2;
            return result;
        }

        public double Subtract(double n1, double n2)
        {
            double result = n1 - n2;
            return result;
        }

        public double Multiply(double n1, double n2)
        {
            double result = n1 * n2;
            return result;
        }

        public double Divide(double n1, double n2)
        {
            double result = n1 / n2;
            return result;
        }
    }

    public class CalculatorWindowsService : ServiceBase
    {
        public ServiceHost serviceHost = null;
        public CalculatorWindowsService()
        {
            // Name the Windows Service
            ServiceName = "WCFWindowsServiceSample";
        }

        public static void Main()
        {
            ServiceBase.Run(new CalculatorWindowsService());
        }

        // Start the Windows service.
        protected override void OnStart(string[] args)
        {
            if (serviceHost != null)
            {
                serviceHost.Close();
            }

            // Create a ServiceHost for the CalculatorService type and 
            // provide the base address.
            serviceHost = new ServiceHost(typeof(CalculatorService));

            // Open the ServiceHostBase to create listeners and start 
            // listening for messages.
            serviceHost.Open();
        }

        protected override void OnStop()
        {
            if (serviceHost != null)
            {
                serviceHost.Close();
                serviceHost = null;
            }
        }
    }

    // Provide the ProjectInstaller class which allows 
    // the service to be installed by the Installutil.exe tool
    [RunInstaller(true)]
    public class ProjectInstaller : Installer
    {
        private ServiceProcessInstaller process;
        private ServiceInstaller service;

        public ProjectInstaller()
        {
            process = new ServiceProcessInstaller();
            process.Account = ServiceAccount.LocalSystem;
            service = new ServiceInstaller();
            service.ServiceName = "WCFWindowsServiceSample";
            service.StartType = ServiceStartMode.Automatic;
            Installers.Add(process);
            Installers.Add(service);
        }

        public override void Install(System.Collections.IDictionary stateSaver)
        {
            base.Install(stateSaver);
        }
    }
}


rybolt
Posts: 8
Joined: Fri Jul 30, 2010 9:07 pm

Re: HELP: Creating installer with basic .net windows service

Is there any reply from _Advance Installer_ , or am I just left on my own ? At the least, can you please confirm if it ( .NET Installer class - Custom Action ) is supposed to work? That's not too much to ask is it.
Bogdan
Posts: 2791
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: HELP: Creating installer with basic .net windows service

Hi,

Sorry for the late reply. What happens is that you need to overwrite one of the methods "Install", "Rollback", "Commit", "Uninstall" corespondent to what you set
in the "Action" parameter. (Just like you did for the "OnStart" and "OnStop" service methods.)

Here are more details about the NET Installer class custom action.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rybolt
Posts: 8
Joined: Fri Jul 30, 2010 9:07 pm

Re: HELP: Creating installer with basic .net windows service

Bogdan wrote:What happens is that you need to overwrite one of the methods "Install", "Rollback", "Commit", "Uninstall" corespondent to what you set
in the "Action" parameter.
My action is "Install". From my previous post:

Code: Select all

  public override void Install(System.Collections.IDictionary stateSaver)
        {
            base.Install(stateSaver);
        }
and quoting from the link you provided:
It must have a class that inherits from the Installer classes and the RunInstaller attribute set to true.
From my previous post:

Code: Select all

  [RunInstaller(true)]
    public class ProjectInstaller : Installer
    {
Please advise?
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: HELP: Creating installer with basic .net windows service

Hello,

The code seems correct. Please make sure your custom action is set as deferred with no impersonation and set after the InstallFiles standard action.
Let me know if this helped.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
lokesh
Posts: 23
Joined: Tue Jul 31, 2012 11:45 am

Re: HELP: Creating installer with basic .net windows service

Hi,
I want to Deploy WCF Web service,using advance installer.
How can i achieve this task.
I am beginning to this.
Please guide me.
Awaiting for your reply..


Regards,
Lokesh.J
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: HELP: Creating installer with basic .net windows service

Hello Lokesh,

In order to achieve this you can write your service as an Installer Class custom action and install it using a ".NET Installer Class Action" predefined custom action. Also, you can take a look on "How to: Host a WCF Service in a Managed Windows Service" article which should be useful for you.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
lokesh
Posts: 23
Joined: Tue Jul 31, 2012 11:45 am

Re: HELP: Creating installer with basic .net windows service

Hi Daniel,
I followed the Installer Class Custom Action link, in that Sample application provided for Visual studio 2005, now i am working in Visual Studio 2012, in that No option available for creating the Setup.
Please give me some other option to achieve this task.
Can i get any sample aip for achieving this task in Visual Studio 2012?????

Regards,
Lokesh.J
lokesh
Posts: 23
Joined: Tue Jul 31, 2012 11:45 am

Re: HELP: Creating installer with basic .net windows service

Hi,
I am having one doubt, please clarify it.
I created WCF Services in Visual studio 2012 and the output of that WCF services is dll file.
Now i want to install the respective WCF service in Window service using msi package and it should start automatically using Advance installer.
It is possible to Achieve this task?
How to put entry in window service and it should start automatically using Advance installer?
Please Guide me..
Please Reply me..


Regards,
Lokesh.J
lokesh
Posts: 23
Joined: Tue Jul 31, 2012 11:45 am

Re: HELP: Creating installer with basic .net windows service

Hi Advanceinstaller team,
Now i am trying to create MSI package for dll, which is created in Visual studio 2012 and .net framework 4.5.
I added entire file in files and folders tab, in service tab ->service to install->New service installation->added the dll file, and i build the project.
I am getting this error.
Please tell me what is wrong with me.
Do some replies..



Regards,
Lokesh.J
Attachments
Error message during installation
Error message during installation
quickreturns.png (170.05 KiB) Viewed 14422 times
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: HELP: Creating installer with basic .net windows service

Hello Lokesh,

I'm not sure why this happens. Can you please try to manually install and start the service on the target machine? If the service fails to start manually then it means there is a service development issue. Also, can you please make sure the "Installation Type" field, from "Install Parameters" page, is set to "Per-machine only (fails if user is not administrator)" and see if the behavior still persist?

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”