I developed new service using .net 4.0 c#, I want now to install to hosting server which does not contain visual studio command promot and installUtil.exe . How can Install the service to the server? It is required to install the VS version ?
Go to "C:\Windows\System32"
Right click on "cmd.exe" and "Run as administrator"
And run "InstallUtil.exe" like that:
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe" "C:\src\Service.exe"
The first parameter is the full path of InstallUtil.exe
For 64 bit executables use following:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe
For 32 bit executables use following:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe
The second parameter is the full path of Service.exe to be installed.
I find the solution :
1- copy 'InstallUtil.exe' file to c: dirve in the server.
2- copy to the service execution file to same place.
3- open command promot in 'administrator mode'(run as admin)
4- write the following command : c:\InstallUtil c:\serviceName.exe
Note : ensure that the service and Installer are both 32-bit or 64-bit
I suggest you a small refactor to implement the whole service using Topshelf and you'll be able to install your Windows services with no additional tool than the service executable itself.
For example, yourexecutable install, yourexecutable uninstall, yourexecutable stop, yourexecutable start...
Related
I'm running a .Net Core microservice on Linux (Ubuntu) and am trying to remote debug with Visual Studio over SSH. But the service is run under the user svcuser and my user is mainuser. Main user is in the same group as the service user.
In visual studio, I can see the process that the service is running under, but when I try to attach I get:
One or more errors occurred. Failed to attach to process. The .Net Debugger has insufficient privileges to debug the process. To debug this process, vsdbg must be running with root permissions.
I checked in MS documentation but for Linux all they have is this: https://learn.microsoft.com/en-us/visualstudio/debugger/remote-debugging-dotnet-core-linux-with-ssh?view=vs-2019 which has no info on running the service with a different user
And the only info they have on fixing such a problem is for windows only: https://learn.microsoft.com/en-us/visualstudio/debugger/error-the-microsoft-visual-studio-remote-debugging-monitor-on-the-remote-computer-is-running-as-a-different-user?view=vs-2019
If you have sudo privileges then this is relatively easy, and can be kept secured to those users with sudo privs. Avoids needing to reconfigure users/environments, and allows you to debug any process on the machine regardless of which user account it is running as.
If you use Visual Studio to make an initial attempt to debug you will find that a ~/.vs-debugger folder has been created in the home directory of the user account you were attempting to use. This command will help you locate the vsdbg binary which was installed. You can install VsDbg manually but I find leveraging the automated process is easier. If you are using VSCode this becomes a manual process, and an exercize left for the reader, but I would still use VS2019 IDE to prep the target just to keep things consistent between tools.
find ~ | grep vsdbg
For my installation the binary is located at ~/.vs-debugger/vs2019/vsdbg and this path will most likely change over time.
First, rename the binary to something convenient:
mv ~/.vs-debugger/vs2019/vsdbg ~/.vs-debugger/vs2019/vsdbg-bin
Second, create a script to replace the binary:
touch ~/.vs-debugger/vs2019/vsdbg
chmod 770 ~/.vs-debugger/vs2019/vsdbg
nano ~/.vs-debugger/vs2019/vsdbg
The script content might look something like this, note the full path to vsdbg-bin, the use of $# ensures all command-line args passed to your script are forwarded to VsDbg.
#!/bin/bash
sudo ~/.vs-debugger/vs2019/vsdbg-bin $#
Now retry your debug session from Visual Studio, if you did things correctly you should be able to attach to any remote process on the target machine using SSH->VsDbg. "Works on my machine." ;) This was confirmed with VS2019 16.8.4, .NET 5.0, and VsDbg 16.9.20122.2 debugging an ASP.NET Core application running on Debian 5.4.8 (x64) launched by systemd under a service user account in Azure. "Sweet."
HTH!
I have a windows service project in Visual Studio that I inherited from another developer, and I'm struggling to deploy the service to our server.
Is it possible to copy the build files from the Release folder to the server, and then run installutil on the exe?
I've tried it, and although the service install successfully, I'm getting an error 1053 when I start the service that
The service did not respond to the start or control request in a
timely fashion
Or is a setup project the only way to go?
If you just want to install a service some way other than an install utility, you can copy the output of the release folder of a windows service project to a directory and register the service using a Powershell command.
At the moment I have a Windows Service and App (Desktop Tray Win Form App with Stop/Start buttons to stop the service and a PING to check the 3rd party API it uses it working and obtain the current balance - It's a Betfair Betting app)
At the moment I am running this off my Win 7 64 bit Desktop but we are moving to a dedicated server Win 2012.
Both the Win Service/Form are in the same project and they reference a DLL which I made that has all the code inside (connects to the DB, 3rd party Betfair API, gets runner/winner info, renews session info etc).
The Windows Server does NOT have Visual Studio on it.
Can I just copy my DLL up to the server, put it in Windows/System32 and Regsvr register it and then copy the .EXE for my Form and Service up to the server?
Also without having the VS Toolset to register a Win Service on a machine what commands do I need to run to install the Windows Service on the Server.
These are 2 distinct solutions, one with the DLL code, one with the Service Project and Win Form Project.
I just want to know the best/quickest/easiest/proper way of getting it to work on the new server without having VS on it to register the service.
Can I just copy the code up to a folder (should it go in a specific folder on the server - the log files are piped out into it's own sub folder of /programdata) and run installutil [PATH TO EXE] to install the Service or is there something more I need to do.
As there are two solutions I can't (or don't know how to) create a deployment package with all the right links and references in across solutions.
However should it be more complicated than..
-Copy DLL to System32
-Regsvr my DLL
-Build the service/win form project on my computer then copy the .EXEs up somewhere
-Run installutil [PATH TO EXE] to register the service
-Double click the windows form to open it (should auto start on reboot and sit in desktop tray)
All in .NET 4.5, Was built in vs 2012, 64 bit, C#
Thanks for any help in advance
Creating a deployment package is the better option, but, because it's not a option for you, the regsvr32 and installutil option should do the job.
Hope it helps!
I have made a Windows Service that reads an excel sheet and updates the values in database. The service just works fine when I install it from the visual studio command prompt.
I have also made an exe file using the other projects option in Visual Studio. When I install that the exe I made, I cannot see my service in services panel of control panel=>System and Security=>Administrative tools=>Service.
I've run into similar issues with production services I've made.
Carefully follow the solution as described here:
http://msdn.microsoft.com/en-us/library/zt39148a(v=vs.80).aspx
Note that the key is creating the "installer" service class in the service project. This creates the output you will have the MSI "install" and will specify what account will be used to run the service, etc.
I have a wpf application and I made a setup, and during installation i need to create database, and edit Connectionstring (app.config). So I made CustomAction add Installer.cs and override Install method and it done.
Now i need to install SqlServer Express from my setup, ie before creating database I should check whether the machine have installed sqlserver if not it should install form my application setup.
As far i know using process.start() i can run exe, but problem i am facing where i should keep sql.exe and how to get path
provide any usefull link much appreciated
ScreenShot:
You can use dotNetInstaller or similar bootstrapper. This solution create only one installer that install other pre-requisites and then execute your Visual Studio setup.