It sounds as if you are expecting the application to execute on the server just by placing it on the server. Unfortunately, that's not what happens. The application will be run on the client machine that invoked it. If you want the code to execute on the server, you should use .NET remoting or switch to a web-based app.
Anyway, you can get the user name from System.Environment.UserName property and the ip addresses (there can be more than one) from System.Net.Dns.Resolve(hostname).AddressList
:
: I am developing an application in .net 2003 on a LAN.
:
: Exe is distributed only on the server and the client
: must make manually a shortcut of server application
: in order to use it (that has a variety of benefits).
:
: The problem is: When the application starts, how to
: know from which IP or user name the shortcut is
: executed?
:
: example app:
:
:
: class MainClass
: {
: static void Main()
: {
: string userNameOrIpAddress = ???;
: Console.WriteLine( userNameOrIpAddress );
: }
: }
:
:
: When the server executes the app output is: TheServerName or 192.168.0.1
: When the client executes the app output is: TheClientName or 192.168.0.2
:
: Once again there is only one exe in the whole LAN (on the server)..
:
:
: I would appreciate any help on this subject,
: Thanks,
: