BloggingAbout.NET
Thoughts of developers

Deploying a custom BizTalk Adapter in a merge module (and registry trouble)

I've been struggling the last two days to deploy a custom BizTalk adapter using a merge module. My idea was to deploy the binaries and add the necessary registry keys using standard installer technology and then run a custom script to register the adapter in BizTalk using WMI. It didn't work in one go.
 
If you create a adapter project using the adapter wizard, a registry file gets created as well that you need to merge into the registry to get the stuff working. These keys are all in the space HKCR\CLSID\<yourkey>. As you can read in this Registry Architecture article from the Windows IT Library the HKCR is in real life a merged key consisting of the HKLM\Software\Classes and the HKCU\Software\Classes keys. So computer settings and user settings in one place. What happens if you create a key there? I don't really know, but it turns out that in most cases exactly what you want (the adapter works) but in some case not. In my case it didn't.
 
When I ran my setup the installation succeeded but the WMI script failed. When I monitored using RegMon from www.sysintenals.com, it turned out that the WMI Service (wmiprvse.exe) tried to read the HKCU\CLSID\<mykey> value and it couldn't. 
 
Since I think an adapter is a computer owned object, I decided that the keys needed to be computer settings, so instead of adding them to HKCR\CLSID, I added them to HKLM\Software\Classes\CLSID and now the WMI script does succesfully register.
 
For the interested few, here's the WMI script that registers an adapter in BizTalk using C# (this script requires you to reference System.Management both as a DLL and as a using statement):
 
    PutOptions options = new PutOptions();
    options.Type = PutType.CreateOnly;
 
    //create a ManagementClass object and spawn a ManagementObject instance
    ManagementClass newAdapterClass = new ManagementClass("root\\MicrosoftBizTalkServer", "MSBTS_AdapterSetting", null);
    ManagementObject newAdapterObject = newAdapterClass.CreateInstance();
           
    //set the properties for the Managementobject
    newAdapterObject["Name"] = "<your adapters name>";
    newAdapterObject["Constraints"] = "<yourconstraints>";  //see the registry file!!
    newAdapterObject["MgmtCLSID"] = "<your adapter clsid>"; //see the registry file!!
            
    //create the Managementobject
    newAdapterObject.Put(options);
    System.Console.WriteLine("Adapter has been created successfully");

Posted Sep 30 2004, 09:38 AM by Carlo Poli
Filed under:

Comments

Carlo Poli wrote re: Deploying a custom BizTalk Adapter in a merge module (and registry trouble)
on 12-10-2004 11:24 AM
This was just what I was loking for !!!

Worked first time.

VC
Carlo Poli wrote re: Deploying a custom BizTalk Adapter in a merge module (and registry trouble)
on 12-23-2004 2:21 PM
Why didn't you use the standard MSI stuff
i imported the registry file into my installer project modified some keys....

I set some properties to create the key Always
( don't forget to do this always on every level of a key. )

and it worked for me.....
Copyright © 2003-2008 BloggingAbout.NET
Powered by Community Server (Commercial Edition), by Telligent Systems