0

I have built a Windows Service app in .NET (C#C) that is currently running on my local PC (Win& 64 bit) and it has it's own Event Log File as well as a custom log file for post debugging which logs out to c:\ProgramData\MyAppName\.

I have the main 2 DLLs in one project which has all the main functional code.

These are hooked into by the Service VS Project which also contains a Windows Form Project which sits in desk tray and gives me a status on the service, as it uses a 3rd party API, whether the API is up and running, any current error, plus it has buttons enabling me to stop/start the service if I need to.

However I am having to move this all to a Windows 2012 Server and there are a few issues I need to resolve.

  1. There is no Visual Studio on the server so no directories for me to place my projects, rebuild them and run them and let the other apps hook into the DLLs which I have to do with "Add reference" etc.

Should I download VS Web Edition or something to the server to make this easier to manage / debug / code if I need to?

Or is there another way e.g just copy the DLL's and regsrvr them to install then copy the service/app to the server and it would automatically have references to it working and if not what is the procedure.

The main code is in the DLL which I built which also comes with a JSON 3rd party API built DLL.

These both get re-created when I rebuild the main project, then I have to remove and re-add them both to the service and the win forms projects before rebuilding them for them to run correctly.

How do I go about this without VS on the server

  • can I keep the debugging/making of the code to my PC and just copy the files over? -will the links to the DLLS from the Service/App still work despite the paths being different? -If not what should I do? -Also where is the best folder to store them?

Also I notice despite me having admin/root access to the server (RD/SFTP/Win Share), I cannot see a c:\ProgramData folder on the C:\ drive. This is where all the logging from my app when it's running 24/7 goes when running on my PC. It creates one log file per day, 2 historical - all for post process debugging etc.

Is this because it's a Win 2012 Server and the code I use to get the path in my project which is

this.Logpath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\" + NameOfMyApp;

works differently e.g Environment.SpecialFolder.CommonApplicationData is a different folder on Win 2012, or do I need to do something to show the ProgramData folder up so I can browse it normally?

I remember recently when I did a Windows Update on my Win7 machine something mucked up (apparently common with Win7) and I couldn't see the ProgramData folder then (service was still running) - until my profiles were swapped over (it was using a default temp profile which is why all my desktop icons went along with bookmarks and folders).

So I am trying to move these 2 VS projects (or the working code they create) from my Win7 64 bit machine to a Win 2012 64 bit server.

What are the best steps to take to get everything working and the folders all showing (programdata), plus the service up and running without having Visual Studio on the server?

TylerH
  • 20,799
  • 66
  • 75
  • 101
MonkeyMagix
  • 677
  • 2
  • 10
  • 30

1 Answers1

0

Firstly you don't need to have Visual Studio installed on the server to run the service. If you create an installer for the application you'll be able to insure that all the dependencies (both ones within the solution and external ones) are installed along with your application. There are a number of programs/plugins that create installers.

Secondly, change your application so that it uses non-system folders to write logs etc. This way you can install it anywhere without having to have lots of checks to see what OS you are installing under. Also have the code to check for the existence of these folders and create them if they're not present.

Thirdly, you can get your code to create the Event Log if it doesn't exist - though this requires admin level access, so this would be best done by the installer so you can run your service under a user account.

ChrisF
  • 134,786
  • 31
  • 255
  • 325
  • Well it uses the Enviroment variables to get the path for where it should create the folder (and creates if not there - same with Event Log) - but I just thought for security they had stopped apps storing files all over the OS and created the ProgramData folder for that exact purpose. The problem is that there 2 projects 1 my DLL with all the code that includes the JSON DLL, then the other project which references those 2 DLLS in both the Service and Windows Form app, how do I create an installer across both projects? – MonkeyMagix Jul 04 '16 at 13:00