S
SteveM
I am needing to get the environment variables (or at the very least
USERNAME and COMPUTERNAME) from a calling method in my (receiving)
library. So far I know how to get the method name, the class name and
even the file path of the calling method. I also know how to get the
line number where the call was made to my program from the other one,
but I also need to log the userName and the computerName running the
method that called mine. Is there a way to do that?
The reason I am doing this is that I am trying to convert an existing
Perl module that we have been using to C# (2.0).
The Perl code in the calling app is a simple one line statement: use
usageTracker();
I have something similar for the C# version: using (UsageTracker ut =
new UsageTracker()) {}
In the UsageTracker library, I use Reflection.MethodBase and
StackFrame to get the filepath of the calling program, the class name,
and the method name. I can also get the line number where the using
statement is being placed in the calling program. As I said I am just
lacking the userName of the user executing the code that calls mine,
and the machine name where the code is running. We use this
information to track usage of various tools we produce.
I hope there is a way to do this at runtime, if so please let me know
Thanks
-SteveM
USERNAME and COMPUTERNAME) from a calling method in my (receiving)
library. So far I know how to get the method name, the class name and
even the file path of the calling method. I also know how to get the
line number where the call was made to my program from the other one,
but I also need to log the userName and the computerName running the
method that called mine. Is there a way to do that?
The reason I am doing this is that I am trying to convert an existing
Perl module that we have been using to C# (2.0).
The Perl code in the calling app is a simple one line statement: use
usageTracker();
I have something similar for the C# version: using (UsageTracker ut =
new UsageTracker()) {}
In the UsageTracker library, I use Reflection.MethodBase and
StackFrame to get the filepath of the calling program, the class name,
and the method name. I can also get the line number where the using
statement is being placed in the calling program. As I said I am just
lacking the userName of the user executing the code that calls mine,
and the machine name where the code is running. We use this
information to track usage of various tools we produce.
I hope there is a way to do this at runtime, if so please let me know
Thanks
-SteveM