This post was originally published here

Today while I was developing a new BizTalk Server solution that communicates with the Oracle database, I encountered a familiar issue that I forgot to document in the past:

Microsoft.ServiceModel.Channels.Common.MetadataException: The assembly required for type mapping not found.

That forced me to once again lose time not only to remember but to find how I could solve this.

Cause

This error happens when you try to call an Oracle Procedure, function, or package that contains User-Defined Types or UDTs. The UDTs can be present in the following artifacts:

  • Interface tables and interface views containing UDT columns.
  • Database tables and views containing UDT columns.
  • Packages, stored procedures, and functions containing UDT parameters.

Oracle UDTs help represent complex entities as a “single” object that can be shared among the applications.

BizTalk Server supports Oracle UDTs, but unlike what happens with SQL Server, which natively supports these types, in Oracle, we need to configure some more properties and generate a UDT DLL.

When this error occurs, two things may happen or maybe the reason:

  • You forgot to configure, in the Schema generation, the following properties:
    • GeneratedUserTypesAssemblyFilePath
    • GeneratedUserTypesAssemblyKeyFilePath
  • Or you forgot in runtime (aka receive location or send port) to configure the following property:
    • userAssembliesLoadPath

Solution

To solve this issue, we need to guarantee to perform the following steps:

  • It is necessary to create a signed assembly (DLL) of the User-Defined Types (UDTs) created in Oracle and that correspond to those interpreted by the WCF-Oracle Adapter. To do this, when creating the schemas from the Consume Adapter Service option, these assemblies must be created specifying:
    • On the GeneratedUserTypesAssemblyFilePath property, we need to provide a full path and name of the DLL that the wizard will create for us.
    • And on the GeneratedUserTypesAssemblyKeyFilePath property, the strong name key (.snk) path that the wizard will use to sign the DLL.

Both these properties are present in the UDT .NET Type Generation – Design Time section of the Binding Properties.

Once again, this will create for us a UDT DLL on the path we define and that we need to use in runtime:

Once we deploy our schemas and create the receive location or send port, we then need to make sure that we configure the following property with the path to the UDT DLL:

  • userAssembliesLoadPath 

Notice: even if you deploy the UDT DLL to GAC (what is advisable), you still need to configure the path to the UDT DLL in this property,

After these steps, you can successfully communicate with Oracle using an Oracle Procedure, function, or package that contains User-Defined Types.

Hope you find this helpful! So, if you liked the content or found it useful and want to help me write more, you can buy (or help me buy) my son a Star Wars Lego! 

Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc.

He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.
View all posts by Sandro Pereira