Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System.Environment.MachineName exception????

Status
Not open for further replies.

diggityduncs

Programmer
Mar 5, 2002
6
US
Hi, I'm using the following code to get the Machine name in an app

System.Environment.MachineName

On most computers this works fine but on one of our testers computers (machine is a windows 2000 desktop pc), it's throwing the following exception.

Request for the permission of type System.Security.Permissions.EnvironmentPermission, mscorlib, Version = 1.0.50000.0, Culture = neutral, publicKeyToken = blahblahblah failed.

I have no idea what is causing this. I tried messing around with the .Net Configuration. Figured mscorlib didn't have permission rights.


also.........

I can't get any computer information in general. Trying to do some WMI core queries as well from code and getting a "Security Error" Exception. Below is the code that gets the disk size.

public string GetsDiskSize(){
ManagementClass cimobject;
ManagementObjectCollection moc;

cimobject = new ManagementClass("Win32_DiskDrive");
moc = cimobject.GetInstances();

try { // BIOS INFO
foreach(ManagementObject mo in moc){
this.m_sDiskSize = GetSystemValue("Size",mo);
mo.Dispose();
break;
}
}
catch(Exception ex){
System.Windows.Forms.MessageBox.Show("GetsDiskSize " + ex.Message);
cimobject.Dispose();
moc.Dispose();
return ex.Message;
}
cimobject.Dispose();
moc.Dispose();
return this.m_sDiskSize;
}




Thx for your time,
Paul
 
Does the user running this have local admin rights?

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Yes user has local admin rights. Trying to simulate this on my computer as well. Know of the ways to remove rights in .Net

thx,
Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top