Hi, I'm using the following code to get the Machine name in an app
System.Environm ent.MachineName
On most computers this works fine but on one of our testers computers
(machine is a windows 2000 desktop pc, not a networking share either),
it's throwing the following exception.
Request for the permission of type
System.Security .Permissions.En vironmentPermis sion, 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;
ManagementObjec tCollection moc;
cimobject = new ManagementClass ("Win32_DiskDri ve");
moc = cimobject.GetIn stances();
try { // BIOS INFO
foreach(Managem entObject mo in moc){
this.m_sDiskSiz e = GetSystemValue( "Size",mo);
mo.Dispose();
break;
}
}
catch(Exception ex){
System.Windows. Forms.MessageBo x.Show("GetsDis kSize " + ex.Message);
cimobject.Dispo se();
moc.Dispose();
return ex.Message;
}
cimobject.Dispo se();
moc.Dispose();
return this.m_sDiskSiz e;
}
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!