I am very new to the language so please pardon my ignorance.
I am writing a small console application to gather hardware inventory
information. When I run the application locally all works well. It
gathers the needed information and writes that info to a remote SQL
server.
If I put the file in the scripts folder on our AD domain controller (so
that I can use it with login scripts) it fails to run. It also fails
when I run it from any network share. I am a domain admin and I have
admin rights on each of the PC's I've tried to run it on as well as
Full Control of the share and NTFS permissions. After debugging I find
the exception was thrown on this line of code.
myMachineName = Environment.MachineName.ToLower();
The exception is this:
System.Security.SecurityException was unhandled
Message="Request for the permission of type
'System.Security.Permissions.EnvironmentPermission , mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
failed."
Source="mscorlib"
StackTrace:
at System.Security.CodeAccessSecurityEngine.Check(Obj ect demand,
StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.Environment.get_MachineName()
at ITInventory.Program.Main(String[] args)
Any help you can offer would be greatly appreciated.