473,396 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Guru's, what is wrong with this code please?

Here is the error:
An unhandled exception of type 'System.Management.ManagementException'
occurred in system.management.dll
Additional information: Not found

here is the code:

string printerName = "";
foreach (ManagementObject printer in searcher.Get())
{
printerName = printer["Name"].ToString().ToLower();
if (printerName.Equals(@"\\web1\shipping1"))
{
//Console.WriteLine("Printer = " + printer["Name"]);
error occurs here>>> if
(printer["WorkOffline"].ToString().ToLower().Equals("true"))
{

//Class1.printerStatus = printer;
// printer is offline by user
// Console.WriteLine("Your Plug-N-Play printer is not
connected.");
}
else
{
// printer is not offline
// Console.WriteLine("Your Plug-N-Play printer is connected.");
}
}
}

Nov 16 '05 #1
3 1410
"trint" <tr***********@gmail.com> wrote in
news:11**********************@f14g2000cwb.googlegr oups.com:
Here is the error:
An unhandled exception of type
'System.Management.ManagementException' occurred in
system.management.dll Additional information: Not found

here is the code:

string printerName = "";
foreach (ManagementObject printer in searcher.Get())
{
printerName = printer["Name"].ToString().ToLower();
if (printerName.Equals(@"\\web1\shipping1"))
{
//Console.WriteLine("Printer = " + printer["Name"]);
error occurs here>>> if
(printer["WorkOffline"].ToString().ToLower().Equals("true"))
{

//Class1.printerStatus = printer;
// printer is offline by user
// Console.WriteLine("Your
Plug-N-Play printer is not connected.");
}
else
{
// printer is not offline
// Console.WriteLine("Your
Plug-N-Play printer is connected."); }
}
}


Trint,

Catch the ManagementException and examine the exception instance
to get more info.

Look here for an example:

http://msdn.microsoft.com/library/de...classtopic.asp

or

http://tinyurl.com/6m8ej

--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 16 '05 #2
Should be:

if(bool)printer.Properties["WorkOffLine"].Value = true)
....
else
"trint" <tr***********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Here is the error:
An unhandled exception of type 'System.Management.ManagementException'
occurred in system.management.dll
Additional information: Not found

here is the code:

string printerName = "";
foreach (ManagementObject printer in searcher.Get())
{
printerName = printer["Name"].ToString().ToLower();
if (printerName.Equals(@"\\web1\shipping1"))
{
//Console.WriteLine("Printer = " + printer["Name"]);
error occurs here>>> if
(printer["WorkOffline"].ToString().ToLower().Equals("true"))
{

//Class1.printerStatus = printer;
// printer is offline by user
// Console.WriteLine("Your Plug-N-Play printer is not
connected.");
}
else
{
// printer is not offline
// Console.WriteLine("Your Plug-N-Play printer is connected.");
}
}
}

Nov 16 '05 #3

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:O5**************@tk2msftngp13.phx.gbl...
Should be:

if(bool)printer.Properties["WorkOffLine"].Value = true)
...
else


<Pedant mode on>

if( (bool)printer.Properties["WorkOffLine"].Value == true)
Extra opening brace. 2 'equals'

<Pedant mode off>
Nov 16 '05 #4

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

Similar topics

2
by: rmn | last post by:
Hi, I'm looking for the translation betwen the color spaces, but I must be mistaken with the methods to use, losing the values. Please, I need a little help of a "coloured guru"....
4
by: Accolo1 | last post by:
Help we are looking for this person, do you know them? William wjohnson@accolo.com Title: BEA WebLogic Portal Guru Job #: 03-04468 Check the pulse of your career! Evolve our eCommerce web...
3
by: Jay | last post by:
Hello, this probably isnt the best place to ask but I can't find a more suitable sql newsgroup so I hope y'all dont mind too much. I have 2 tables; Cellar and Colour CELLAR contains the wine...
67
by: Scott M. | last post by:
Can anyone give me any ideas on why VS.NET 2003 running on XP Pro. (P4's with 1GB RAM) would take over 3 minutes to simply create a new ASP.NET Web Application on http://localhost? It seems that...
3
by: Michael Suess | last post by:
Hi, please feel free to correct me if this is the wrong group to ask this question. I have a blog about parallel programming and concurrency (http://www.thinkingparallel.com if you are...
0
by: Gawn | last post by:
Dear all, Greeding from Thailand. Need help for my news script. I am trying to display news which keywords match the current page keywords. I am using Dreamweaver 8 and PhpMyAdmin to manage MySQL....
16
by: Singulus | last post by:
Hello all, I've searched for similar threads, I've found some bit of useful info here and there, but nevertheless I want to post my questions...So, how can I (we, in fact the forum can benefit...
8
by: Chris LaVelle | last post by:
I don't know the easiest way to explain this so, I'm going to give an example of how it is today....and what I'm trying to accomplish. in the header... typedef struct XXX_ELEMENT_tag { UINT8 ...
3
crabpot8
by: crabpot8 | last post by:
So I am building a web service that generates charts from a large amount of data. The problem I am running into is that to generate one chart, there can be up to 5 requests set. The variable...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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,...

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.