How to fix the error “Exception has been thrown by the target of an invocation.” when using the BRI resolver in the ESB Toolkit and BizTalk 2013

In BizTalk 2009 and BizTalk 2010, there are often problems when installing the ESB Toolkit but then it (almost) always works well. In BizTalk 2013 The BizTalk Server installer now provides the option of installing ESB Toolkit as well. The configuration process is also much simpler so you would think it’s now more integrated with BizTalk Server 2013. Unfortunately, that is not entirely true. Installation has indeed become easier but also there are some new bugs added!

A great feature of the ESB Toolkit is that you can use business rules to select an itinerary based on the content of a received message. But when you have configured an Itinerary Selector pipeline component in BizTalk 2013 to use a business rules policy to select the appropriate itinerary, you get the following error:

“Exception has been thrown by the target of an invocation.”
Exception has been thrown by the target of an invocation
On the BizTalk ESB Toolkit Forum you can see that other users also have this problem so it's starting to seem that this is a bug!


Identifying the exact error

The error “Exception has been thrown by the target of an invocation.” is to generic and doesn't help very much but combined with Error StackTrace you see which .dll file, the method and the object that creates the error. As is often your best friend is Reflector so let’s have a closer look at the “ResolverFactory.Create” method in the Microsoft.Practices.ESB.Resolver.dll.

Yeah but what now? Let's try to copy that piece of code into a new solution in Visual Studio and run and debug it.
Ok, I can now see that an instance of the “Microsoft.Practices.ESB.Resolver.Unity.ResolveProvider” object is going to be created. That's a bit more information but combined with the Inner Exception, we know what's really going on.
InnerException: “Unrecognized element 'typeConfig'. (C:\Program Files (x86)\Microsoft BizTalk ESB Toolkit\esb.config line 153)”


How to fix the bug

The “Microsoft.Practices.ESB.Resolver.Unity.ResolveProvider” object in the ESB Toolkit 2.2 uses the Microsoft Enterprise Library 5.0 and Unity 2.0. When you google/bing on “Unrecognized element 'typeConfig'.” and Unity, it becomes clear that Unity 2.0 uses a new streamlined configuration schema for configuring Unity. Therefore, the esb.config file from the ESB Toolkit must be modified.

The following adjustments should be made:

  • Remove the <typeConfig> element
  • Change the <typeAlias> element to <alias>
  • Change the <type> element to <register>.
  • Remove the <containers> elements and <types> elements.

For more information see The Unity Configuration Schema in Unity 2.0.

Changes in file: C:\Program Files (x86)\Microsoft BizTalk ESB Toolkit\esb.config
esb config


Testing the changes in the esb.config

I used the sample How to: Select an Itinerary Using a Business Rules Policy to test the changes, but first I changed the machine.config file to be able to see BizTalk ESB Toolkit trace output.

To enable the BizTalk ESB Toolkit trace switch, add the following <switches> element to the system.diagnostics section of the Machine.config file.
          <add name="BizTalkESBToolkit" value="4"/>
Now when you receive a message in BizTalk you can see the trace output from the ESB Toolkit. In the last line you can see that the itinerary is found and added to the cache!



These adjustments in the esb.config file are not exactly rocket science yet it has taken me a long time to find the exact error and make the proper adjustments because the original error message was to generic and you have to perform a lot of work to find out what's going wrong!

You can download the updated esb.config file here:

Comments (2) -

6/4/2013 12:07:59 PM #

Another, 'here he is to save the day' blogpost Smile


Sander Nefs
Sander Nefs
7/29/2013 11:53:30 AM #

Though this works great, it has an impact on the available resolvers, as some of the resolvers seem to use Unity.

In my case i couldn't use the Itinerary-Static so i am now used the 'Itinerary';


Pingbacks and trackbacks (2)+

Add comment

  Country flag

  • Comment
  • Preview

About the author

Tomasso Groenendijk lives in Netherlands and is a Solution Architect at Insight. He has over 17 years’ experience in software development and software design. Tomasso is specialized in application integration with a strong interest in the Windows Azure cloud platform. From 2014, Tomasso has been awarded four times with the Microsoft Azure MVP award. He is an active contributor to the integration community through his work on his blog, MSDN samples, TechNet Wiki and also speaking on events.

MVP profile Tomasso Groenendijk
Sentinet Product Specialist
BizTalk360 Product Specialist

Month List