473,669 Members | 2,304 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

exception of type 'System.Managem ent.ManagementE xception'

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.SystemInf ormation.Comput erName.ToString ();
WqlObjectQuery query = new WqlObjectQuery( "SELECT * FROM
Win32_ComputerS ystem");
ManagementObjec tSearcher search = new ManagementObjec tSearcher(query );
object[] name = {"NewName"};
foreach (ManagementObje ct mo in search.Get())
{
mo.InvokeMethod ("Rename", name);
}

This ex. appears everytime I run my application!

An unhandled exception of type 'System.Managem ent.ManagementE xception'
occurred in system.manageme nt.dll

Additional information: This method is not implemented in any class

thanks in adv.
--
LZ
May 8 '06 #1
2 5483

"Lamis" <La***@discussi ons.microsoft.c om> wrote in message
news:D0******** *************** ***********@mic rosoft.com...
| 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.SystemInf ormation.Comput erName.ToString ();
| WqlObjectQuery query = new WqlObjectQuery( "SELECT * FROM
| Win32_ComputerS ystem");
| ManagementObjec tSearcher search = new ManagementObjec tSearcher(query );
| object[] name = {"NewName"};
| foreach (ManagementObje ct mo in search.Get())
| {
| mo.InvokeMethod ("Rename", name);
| }
|
| This ex. appears everytime I run my application!
|
| An unhandled exception of type 'System.Managem ent.ManagementE xception'
| occurred in system.manageme nt.dll
|
| Additional information: This method is not implemented in any class
|
| thanks in adv.
| --
| LZ

Note that this only works on XP or W2K3 or higher.

using (ManagementObje ct dir= new
ManagementObjec t("Win32_Comput ersystem.name=' " + Environment.Mac hineName +
"'"))
{
ManagementBaseO bject inputArgs = dir.GetMethodPa rameters("Renam e");
inputArgs["Name"] = "NewName";
ManagementBaseO bject outParams = dir.InvokeMetho d("Rename", inputArgs,
null);
uint ret = (uint)(outParam s.Properties["ReturnValu e"].Value);
if(ret == 0)
// OK
else
// Failed
}

Willy.

May 8 '06 #2
Hi Willy,,

Yes I noticed.. I have win2000 installed on the machine but it works
perfectly on other machines with XP installed.

Thank you for helping
--
LZ
"Willy Denoyette [MVP]" wrote:

"Lamis" <La***@discussi ons.microsoft.c om> wrote in message
news:D0******** *************** ***********@mic rosoft.com...
| 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.SystemInf ormation.Comput erName.ToString ();
| WqlObjectQuery query = new WqlObjectQuery( "SELECT * FROM
| Win32_ComputerS ystem");
| ManagementObjec tSearcher search = new ManagementObjec tSearcher(query );
| object[] name = {"NewName"};
| foreach (ManagementObje ct mo in search.Get())
| {
| mo.InvokeMethod ("Rename", name);
| }
|
| This ex. appears everytime I run my application!
|
| An unhandled exception of type 'System.Managem ent.ManagementE xception'
| occurred in system.manageme nt.dll
|
| Additional information: This method is not implemented in any class
|
| thanks in adv.
| --
| LZ

Note that this only works on XP or W2K3 or higher.

using (ManagementObje ct dir= new
ManagementObjec t("Win32_Comput ersystem.name=' " + Environment.Mac hineName +
"'"))
{
ManagementBaseO bject inputArgs = dir.GetMethodPa rameters("Renam e");
inputArgs["Name"] = "NewName";
ManagementBaseO bject outParams = dir.InvokeMetho d("Rename", inputArgs,
null);
uint ret = (uint)(outParam s.Properties["ReturnValu e"].Value);
if(ret == 0)
// OK
else
// Failed
}

Willy.

May 10 '06 #3

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

Similar topics

0
1932
by: Ger | last post by:
Hi, I have a problem with a Windows Service that I have created accessing System.Management.dll on a W2k3 environment. The Service runs fine on an XP machine but the same Service causes an error once it tries to access System.Management.Dll. The service is run using a Domain Admin acoount. The code is trying to set permissions for a file and looks like this:
0
864
by: Ger | last post by:
Hi, I have a problem with a Windows Service that I have created accessing System.Management.dll on a W2k3 environment. The Service runs fine on an XP machine but the same Service causes an error once it tries to access System.Management.Dll. The service is run using a Domain Admin acoount. The code is trying to set permissions for a file and looks like this:
1
2165
by: Dan Weatherman | last post by:
Hi all, Using WMI I am attempting to catch and exception when doing a managementscope.connect operation. From the looks of things, this method starts a new worker thread through Interop that then executes the method. My problem is that regardless of what all I use in my catch statements, the system still raises the initial dialog reporting the exception. Eventually, my app catches and handles the exception but I cannot get the initial...
2
4642
by: karthi84 | last post by:
Hi Experts, i have created a web application which has an option to edit the web config file from the web page. when i create an installer for this project using web setup project in VS2008 and install it, the codes are copied to the virtual directory under Inetpub. when i try to edit the web.config file it throws an exception access is denied to web.config file. but the same project works fine if i copy the file to some other location and...
0
8462
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
8382
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8893
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8802
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...
0
8658
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
7405
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
6209
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
4384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2028
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.