In a .NET Windows service (C#), how can I get the computer name?
Is this a reliable method, or should I wrap it in a try/catch?
string CurrentMachineName = Environment.MachineName;
According to the docs, this could generate an InvalidOperationException so you'll need to be aware of that possibility. The risk probably doesn't warrant wrapping it in a try/catch, though.