Martijn's blog - E-Commerce, EAI, BizTalk and .NET

2004/09/10

Property editors & pipeline components

There have been a lot of questions in the newsgroups recently regarding custom type editors within pipeline components.

I've created a sample component in which you choose which database you'd like to connect to and subsequently choose a customer the pipeline component is specific to. These kind of properties could be used to perform customer specific actions within a pipeline component.

Currently, the component implements a UITypeEditor derivement to implement it's editing functionality for choosing a customer. It uses the NorthWind database within the choosen server, and has very little error checking to see whether or not the DBMS exists, etc.

However, it demonstrates the purpose of custom editors for your properties, besides the obvious SchemaWithNone and SchemaList which are already supplied within Microsoft.BizTalk.Component.Utilities.dll and within my Pipeline Component Wizard.

Now for a screenshot, as it usually clarifies a lot (I've removed a portion of the connection string configured):



The component can be downloaded here

Please note this:

1) As BizTalk uses a component called ComponentObjectWrapper to wrap the actual object being handled within the pipeline component editor, and you simply cannot reference Microsoft.BizTalk.PipelineEditor.dll in a decent way without breaking Visual Studio integration with BizTalk, I've applied a "dirty" reflection hack in which I at runtime retrieve the actually instantiated component from this object using reflection, like this:

BindingFlags bindingFlags = BindingFlags.NonPublic | BindingFlags.Instance;
Type t = context.Instance.GetType();
FieldInfo fi = t.GetField("cachedPipelineComponent", bindingFlags);
CustomerSpecificComponent instance = fi.GetValue(context.Instance) as CustomerSpecificComponent;

 

It's a dirty way to get to the object, but it means I don't have to reference any other components and currently seems to be the only way to achieve reading another property from our design-time component.

2) The project has a build event specified which should deploy the component to the GAC. If it doesn't work, please alter it to represent the location of your gacutil installation.

As always, all sourcecode is included, and comments are very welcome!

12 Comments:

  • Cool.

    By Blogger Devdutt, at 4:20 PM  

  • For some reason when i try to add your component to the toolbox it wont add (It compiles fine).

    Then when i try to duplicate your code and use it inside my class the SQlConnection Editor works great, but the "Custom Editor" for the drop down does not work. The field is still treated as a string.

    Any Ideas?

    Scott
    sb_1@yahoo.com

    By Anonymous Anonymous, at 5:23 AM  

  • Did you run gacutil on it?

    By Blogger Martijn Hoogendoorn, at 10:56 AM  

  • I did run gacutil. The assembly installed, it was copied to the pipeline components directory, but when i try to add it to the toolkit i get the following error "You have selected a invalid pipeline component assembly. Please check the security on the assembly if you are loading it from a UNC path"

    Here is a Link to a few screen shots.

    By Anonymous Anonymous, at 4:11 AM  

  • Well i moved your files into a new project and now i can add it to the toolbox. i selected the connection string (northwind database in sqlserver), but when i go to select the customer, it is still treated as a string field instead of the dropdown appearing (as in your screenshot)

    Any help would be apprecaited.

    Thanks,

    Scott

    By Anonymous Anonymous, at 4:59 AM  

  • I looked into the issue and it turns out I was somewhat hasty and made a mistake with defining the namespace for the ResourceManager instance to use. Please change line 31 from using

    ("myComponentNamespace[...]")

    to using:

    ("Macaw.BizTalk.Samples.Customer[...]"

    and the component will appear in the toolbox.

    This error occurs because the VS.NET instance will try to retrieve descriptive information to show in the toolbox and will ignore the component if anything goes wrong in retrieving those properties (name, version, the likes)

    If the field is treated as a plain string value, the custom UITypeEditor instance is not getting fired. The normal reason for this would be if the component is not placed within the GAC.

    I'm awfully sorry for wasting your time by uploading a faulty example component. Please let me know if you run into any more troubles!

    I've uploaded a correct version for you to use.

    By Blogger Martijn Hoogendoorn, at 12:55 PM  

  • I got it working last night as well. Thanks for taking a look at it.

    Scott

    By Anonymous Anonymous, at 7:41 PM  

  • Have you read this article LINK
    on not putting pipeline components in the GAC. If i cant put a component in the GAC can I use custom property editors?

    Scott

    By Anonymous Anonymous, at 2:53 AM  

  • Interesting layout on your blog. I really enjoyed reading it and also I will be back to read more in the future.

    By Anonymous Gadgets UK, at 9:48 AM  

  • Thanks you. Very good post.Unless they can offer a really compelling reason for users to come back, it will be the next Bebo, MySpace
    10755GF

    By Anonymous 10755GF, at 11:20 PM  

  • Thanks you. Very good post.Unless they can offer a really compelling reason for users to come back, it will be the next Bebo, MySpace

    By Anonymous Cannon 10755GF, at 11:24 PM  

  • I am very much pleased with the contents you have mentioned. I wanted to thank you for this great article. Let become a spellcaster in game sims 4 cheats

    By Blogger Sophie Grace, at 8:37 AM  

Post a Comment

<< Home