Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / December 2004

Tip: Looking for answers? Try searching our database.

Cannot install Service App in .Net

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Harshad - 08 Dec 2004 14:31 GMT
Two questions.
1)  I followed Walkthrough of Win Service App.  At the end, when I run Setup
it complains about incorrect user and/or password.  Where does it look for
userid?  I have logged in as Administrator.

2) Why cannot I install the service with ServiceName.exe /install command as
I do for non-dotNet service?

Signature

Thanks for your help.

Harshad Rathod

Vincent Finn - 09 Dec 2004 17:35 GMT
>Two questions.
>1)  I followed Walkthrough of Win Service App.  At the end, when I run Setup
[quoted text clipped - 3 lines]
>2) Why cannot I install the service with ServiceName.exe /install command as
>I do for non-dotNet service?

You can but you have to write it.
If you look in a C++ service you'll see it has a load of code under
the /install (/service)

It's a lot easier in .Net though

Here is a C# version of what you want
You need this as the first thing in your Main function

    Vin

// if we have an argument process it
if (args.Length > 0)
{
    string sSwitch = args[0];
    sSwitch.ToLower();
    switch (sSwitch.Substring(0, 1))
    {
        case "-":
        case "/":
        case @"\":
        {
            sSwitch = sSwitch.Substring(1);
            break;
        }
    }

    string sExe = typeof(RAPIDHouseKeeper).Assembly.Location;
    string sInstallUtil = typeof(object).Assembly.Location;
    sInstallUtil = sInstallUtil.Substring(0,
sInstallUtil.LastIndexOf(@"\"));
    sInstallUtil += @"\InstallUtil.exe";

    AppDomain dom = AppDomain.CreateDomain("execDom");

    switch (sSwitch)
    {
        case "install":
        case "regserver":
        case "service":
        {
            // uninstall before installing (in case it's
pointing to the wrong place)
            string[] asUninstallArgs = new string[2]
{"/u", sExe};
            dom.ExecuteAssembly(sInstallUtil, null,
asUninstallArgs);
            // now install
            string[] asArgs = new string[1] {sExe};
            dom.ExecuteAssembly(sInstallUtil, null,
asArgs);
            return;
        }

        case "uninstall":
        case "unregserver":
        {
            string[] asArgs = new string[2] {"/u", sExe};
            dom.ExecuteAssembly(sInstallUtil, null,
asArgs);
            return;
        }
    }

}
Harshad - 11 Dec 2004 02:55 GMT
Thanks Vincent.

> >Two questions.
> >1)  I followed Walkthrough of Win Service App.  At the end, when I run Setup
[quoted text clipped - 69 lines]
>
> }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.