[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

WMI limits and .NET bugs w/request features

Spartaco

9/25/2002 8:15:00 PM

First of all:

let's look at the IWBemLocator COM interface and the method ConnectServer.

The msdn library docs for this method says that it could hang your program
if you try to connect to a broken server. Well, a broken server can also be
a server behind a firewall. That just means that if you try to use WMI
against a such server your program will hang indefinitely. This sucks.

In order to overcome this big limit, Windows XP added a new property to that
method: WBEM_FLAG_CONNECT_USE_MAX_WAIT. Now The ConnectServer call is
guaranteed to return in 2 minutes or less.

Well, I guess that windows 2000 users can't use this feature so the only way
they can be sure their program do not hang when making WMI calls, is to make
those calls inside a new thread, so it can be aborted if a timeout exceeds.

ok, so what about .net ?

The IWBemLocator interface is used internally by the ManagementScope class
to connect to the server for the wmi query. (thanks anakrino)

The ManagementScope class uses a ConnectOptions class to get the flags for
the ConnectServer method. The ConnectOptions inherits from
ManagementOptions, and the ManagementOptions has a private field called
'flags' that is passed to that method.

So the problem is that you CAN'T set that private field in order to use the
WBEM_FLAG_CONNECT_USE_MAX_WAIT const. Another interesting thing is that the
ManagementOptions class has also another private property called SendStatus
that is used to set the private field flags to the value of that constant!

So, one request: please make that flags field of the managementOptions class
a protected field rather than private, in order to support this new future
of XP.

The problem with .net: The ManagementScope hangs when you try to query a
"broken" server. This derives from what I said about the IWbemLocator
interface.

What's worst with .net is that you can't use the workaround I talked before,
that is making use of a new thread. That's because you can't abort a .net
thread when it is inside unmanaged code!

Well, I don't know what to do about it, can you help me ?

thanks

Spa.-