I want to access WMI using the AutomationFactory
in a Silverlight OOB application.
dynamic locator = AutomationFactory.CreateObject("WbemScripting.SWbemLocator");
dynamic wmi = locator.ConnectServer(".", "\\root\\cimv2");
I now want to add error handling to this.
MSDN states that the return value is a reference to the connected object if the call is successful and that in case of an error I should check the Err
object. However, there are two questions I have with this:
- What is the return value if the call is not successful? null? Some arbitrary pointer that I cannot use?
- How can I access the
Err
object in Silverlight? - How can I detect if the call was successful? May there be any exceptions which I have to catch?
- I've seen some examples using the
using
statement, and some without. Do I have to dispose the dynamic objects manually after I've used them?