views:

271

answers:

2

Hi,

I'm using MgmtClassGen.exe from the .Net Framework SDK to generate some WMI wrapper classes for BizTalk artifacts like hosts, host instances, etc.

I'm using HostSetting.GetInstances() to get the local hosts (local BizTalk Server). This works fine. I'm now looking for a way to do the same for hosts on another BizTalk machine with a different BizTalk management database name. I can't find a way to do this using the wrapper classes. I do want the wrapper classes. Any idea how to connect to BizTalk Management database with name 'MyManagementDB' on server 'ServerX'?

Thanks in advance!

+1  A: 

You can choose a different server to connect to by specifying it in the WMI scope declaration.

In your code you will have something like the following:

ManagementClass objHostSettingClass = new ManagementClass("root\\MicrosoftBizTalkServer", "MSBTS_HostSetting", null);

The first parameter in the constructor call there is the scope. This can include a server name as shown below:

ManagementClass objHostSettingClass = new ManagementClass("\\\\ServerX\\root\\MicrosoftBizTalkServer", "MSBTS_HostSetting", null);

I don't believe that you will need to know the message box name - the WMI MicrosoftBizTalkServer provider should let you access the host instances on the server directly.

EDIT

As Maxime points out in the comment below, there is a way of setting the WMI scope that more integrated with the code generated by the MgmtClassGen.exe tool.

This allows you to set the StaticScope property of the generated classes. This still involves building a string defining the scope but gives a single place to define it. Maxime has a nice post defining a helper class that builds the StaticScope string.

David Hall
Or, to use a more "integrated" syntax, you can take advantage of the fact that strongly-typed classes generated by MgmtClassGen.exe have a "StaticScope" property that you can use to access the relevant artifacts from a remote host.Please look a my blog entry for more information :http://maxime-labelle.spaces.live.com/blog/cns!D8D9369449D177DA!156.entry
Maxime Labelle
Thanks maxime - I've never actually used the MgmtClassGen.exe tool so answered based on WMI first principles. Hopefully you don't mind me editing the above information into my answer to give a better answer.
David Hall
No problem. Glad it helped.
Maxime Labelle
A: 

I know this could be considered off topic since you are somewhat asking specifically of WMI, but there is also a .NET library that provides access to all of the BizTalk artifacts called Microsoft.BizTalk.ExplorerOM.dll. I used it to turn on/off receive locations in a small C# app. Here is a link to my previous Stack Overflow question with more information:

http://stackoverflow.com/questions/1515305/is-there-a-way-to-automate-turning-a-biztalk-receive-location-on-or-off-through-c

Just another option for altering or administrating BizTalk artifacts through code.

Andrew Dunaway