.NET Framework Bookmark and Share   
 index > 64-Bit .NET Framework Development > ManagementClass, ManagementOperationObserver - Process is not firing Completed Event.
 

ManagementClass, ManagementOperationObserver - Process is not firing Completed Event.

I need to execute a command on Remote box and the task is to wait till the execution finishes and then need to do some other steps. i have written following code using ManagementClass and ManagementOperationObserver (for Asynchrous execution), it is working fine with win 2003 boxes but when i execute it on 64-bit it is hanging. ALthough my command got executed it is not able to fire the event Completed(observer Delegate). Appreciate any quick help. here goes my code


Class someClass{

private

bool _wait = false;

void somefunction()
{

ManagementScope

sc = null;

ConnectionOptions co = new ConnectionOptions();

// the observer will get a callback when the object we are executing is ready

ManagementOperationObserver observer = new ManagementOperationObserver();

observer.ObjectReady +=

new ObjectReadyEventHandler(observer_ObjectReady);

observer.Completed +=

new CompletedEventHandler(observer_Completed);

co.Authentication =

AuthenticationLevel.Call;

co.Impersonation =

ImpersonationLevel.Impersonate;

co.EnablePrivileges =

true;

// create scope to the remote machine

sc =

new ManagementScope(string.Format("//{0}/ROOT/CIMV2", _machineName), co);

// create a new management class

ManagementClass processClass = new ManagementClass(sc, new ManagementPath("Win32_Process"), null);


object[] methodArgs = { _files[i].Trim(), null, null, 0 };

//Host.UI.WriteLine(string.Format("\t\tRemoteCommand is: {0}", thisCmd));

Host.UI.WriteLine(

string.Format("\t\tRemoteCommand is: {0}", _files[i].Trim()));

// execute the file/command

processClass.InvokeMethod(observer,

"Create", methodArgs);

while

(!_isComplete)

{

// display the time so that hung process can be detected visually

Host.UI.WriteLine(

string.Format("\t\tWaiting... {0}", DateTime.Now.ToLongTimeString()));

// sleep

System.Threading.

Thread.Sleep(_pollInterval);

}

/// <summary>

/// Command complete event.

/// </summary>

/// <param name="sender"></param>

/// <param name="e"></param>

void observer_Completed(object sender, CompletedEventArgs e)

{

_isComplete =

true;

}

/// <summary>

/// Event handler to process object ready events.

/// </summary>

/// <param name="sender"></param>

/// <param name="e"></param>

void observer_ObjectReady(object sender, ObjectReadyEventArgs e)

{

_exitCode = e.NewObject.Properties[

"ReturnValue"].Value.ToString();

_processID = e.NewObject.Properties[

"ProcessId"].Value.ToString();

}

manjunath15

Still waiting for reply on this thread!

manjunath15

Hello
can you tell me the PC's configuration

Same type of problem coming to me on 64 bit Vista andprogram was properly running on Vista 32 bit.

I changed my project's solution platform to X86.

It may help you

Amolpbhavsar

You can use google to search for other answers

Custom Search

More Threads

• WebBrowser not scrolling on 64 bit xp
• Developing 64 bit asp.net application
• System.AccessViolationException in System.Collections.Generic.List`1.Enumerator.MoveNext() in IIS6
• Invoking executable, but cannot read registry
• Urgent: 64 bit Compile for web application at .NET Framework 2.0
• Installing VC++ .NET 2003 on Athlon 64?
• clickonce ProcessorArchitecture
• Problem: 64-bit MFC C++ DLL calling 32-bit C# class library through COM
• Is my app ready for 64 bit
• RSACryptoServiceProvider FatalExecutionEngineError in Vista 64 - looks like a bug