Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Automate Component Registration Using MTXAdmin : Page 2

Leverage Microsoft Transaction Server's component model to register your components without breaking a sweat or leaving the IDE.


advertisement
Once you've connected and populated the packages collection, you can begin to do something useful. First, take a look at removing a component. The basic principal is straightforward enough: iterate through the component collections until you find one or more components matching the DLL filename in which you are interested. The devil is in the details, however, and there are a few items worth pointing out.

Multiple DLL files with the same filename can be registered in different packages on the same server. This is perfectly legal, of course, because each component has a different Class Id. Thus, using the Class Id seems to be the best way to identify a componentbut is it? In a development environment, binary compatibility is broken from time to time. When this happens, your component's Class Id changes, making it a less than ideal method of identification. Most developers do not rename their DLL file, however, so stick with the filename. So how do you solve the problem of multiple components sharing filenames?

As you can see in Listing 1, the RemoveComponents method has a PackageName parameter. If you know the name of the package in which your component resides, passing the package name will eliminate the problem. As an added benefit, your component is removed more quickly because only the specified package is searched. If your project uses multiple packages, but conforms to some type of naming convention, you can also use a wildcard in the package name. So, passing "ACME*" as the package name searches only those packages beginning with "ACME."



When the package matches the specified name or wildcard, iterating through its components is fairly straightforward. Begin by asking the package object to populate a Components collection.

Set oComponents = oPackages.GetCollection _ ("ComponentsInPackage", oCurrentPackage.Key) oComponents.Populate

After populating the components collection, you move through the components backwards. This preserves the array indexes as we delete components. Next, call the component objects' "Remove" method. Once you've looped through all the components, tell MTS to apply your changes by calling the "SaveChanges" method.

For lngIndex = oComponents.Count - 1 To 0 Step -1 Set oCurrentComponent = oComponents.Item(lngIndex) . . . If strCurrentDLL = strDLLToRemove Then oComponents.Remove lngIndex UNC = PathToUNC(oCurrentComponent.Value("DLL")) PackageName = oCurrentPackage.Name RemoveComponents = True End If Next If RemoveComponents = True Then oComponents.SaveChanges Exit For End If

One last item to note is that the UNC path of the DLL file is returned to the calling process. This will be useful when you write your add-in. Once a component has been removed from a package, copy the new version to this UNC path and register your latest and greatest.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date