473,765 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Environm ent.MachineName exception???

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), 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;
}
Thx for your time,
Paul
Nov 22 '05 #1
0 1521

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
378
by: duncsss | last post by:
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...
3
3409
by: Bryan Martin | last post by:
I have a program which has ran every night fine until last night. Now it bombs with the following errors. I have also broke this down to its simplest form for sending the mail (http://support.microsoft.com/default.aspx?scid=KB;EN-US;314201) which gives the same error. This server does not have any firewall software running on it as it is the exchange server for the domain. I can also telnet smtp and send mail using localhost,...
0
1062
by: Paul Duncan | last post by:
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, not a networking share either), it's throwing the following exception. Request for the permission of type System.Security.Permissions.EnvironmentPermission, mscorlib, Version =
1
2928
by: Brian | last post by:
I've looked through the previous posts on this one and have verified permissions and location of my Dlls, but I am still getting an exception when I try to Load an assembly. The directory where my Dlls are located give the ASPNET user full control, and all Dlls used by the Assembly in question are in the local folder with the rest of the web application Dlls. Could someone take a look at my error and shed some light on this?
1
8174
by: Mchuck | last post by:
I've seen several newsgroup topics everywhere concerning this, as well as a couple of articles from the MSDN website, but this error still baffles me. It has to do with using the Image.FromStream(...) function to load an image into a PictureBox control from a byte array received from an SQL Server database. Here's a snippet of what I've been trying to achieve: ----------------------------
11
3756
by: Nurit N | last post by:
This is the third newsgroup that I'm posting my problem. I'm sorry for the multiple posts but the matter becoming urgent. I hope this is the right place for it... I have created a very simple batch file (echo hello world) and was trying to retrieve the standard output but every time I run the code it returns ExitCode as 1.
3
13799
by: Ankit Aneja | last post by:
This is my problem. I am using Visual 2003, .Net framework 1.1 and the Application Block I configured the DAAB using the Enterprise Library Configuration now this is the error which is coming Security Exception Description: The application attempted to perform an operation not allowed
2
5493
by: Lamis | last post by:
Hi, I need urgent help, this is my code to rename my hostName: (MY computer is not member of domain) string compName = System.Windows.Forms.SystemInformation.ComputerName.ToString(); WqlObjectQuery query = new WqlObjectQuery("SELECT * FROM Win32_ComputerSystem"); ManagementObjectSearcher search = new ManagementObjectSearcher(query);
5
8331
by: Henry Stock | last post by:
I am trying to understand the following error: Any thing you can tell me about this is appreciated. Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. Exception Details: for the permission of type
0
3699
by: =?Utf-8?B?am1hZ2FyYW0=?= | last post by:
I have a Windows service written in C# that is configured to automatically start. Sometimes - maybe 20% of the time - the service fails to start due to an exception in WMI code. I haven't made my service dependent on WMI (or any other service) because it appears that .net WMI calls automatically start the WMI service if necessary. Below are the details. What causes this? How can I make this code work 100% of the time? The code is trying to...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9957
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9835
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8832
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7379
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5276
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.