0

I have a WPF application that should have been designed as a service since I realized that when the user logs out, the application closes. The WPF side has just a few settings such as DB name / password, OAuth token that is needed by the service. What is the best way to transfer that info from the WPF view to the Windows service? I had thought I would use registry settings, but it looked like that is getting phased out with UWP so I figured I would learn what the new "right" way was.

I would of course not want to store DB info in a plain text file.

Alan
  • 2,046
  • 2
  • 20
  • 43

1 Answers1

0

What is the best way to transfer that info from the WPF view to the Windows service?

You could basically create a new Windows Service (.NET Framework) project in Visual Studio and move your current code over to this one.

For more information about how to create Windows services, you should check out the documentation on MSDN:

How to: Create Windows Services: https://learn.microsoft.com/en-us/dotnet/framework/windows-services/how-to-create-windows-services

The service may connect to the database in the same way that the WPF application does since both are based on the same version of the .NET Framework.

If you want to share data between a client app and the service, you could for example use a database. You might use a local database or a plain file if the service and client app are deployed onto the same machine, or you may use a remote database if thet are not.

mm8
  • 163,881
  • 10
  • 57
  • 88
  • Thank you, I did follow that tutorial yesterday but there has to be some sort of GUI that allows input of the tokens and passwords, and Windows services aren't allowed to have a GUI that I am aware of. – Alan May 15 '18 at 15:09
  • So store the tokens and the passwords in a database or in a file? Or what is your actual question? – mm8 May 15 '18 at 15:10
  • Sorry MM8, the application is to be deployed in a medical office environment where I don't have write access to the DB. Storing the info in a flat .config file isn't very secure when it has the DB passwords, but I guess I could obfuscate the stored data in the flat file using ROT or something, I just wasn't sure if there was a better way. – Alan May 15 '18 at 15:16
  • You can encrypt the file in one way or another: https://stackoverflow.com/questions/5522879/encrypt-password-in-app-config – mm8 May 15 '18 at 15:17