Getting this error:

Error Description: System.Reflection.ReflectionTypeLoadException: 
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

Server stack trace: 
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at Microsoft.Adapters.OracleDB.OracleDBConnectionFactory.LoadUdtAssemblies(String UserAssembliesLoadPath)
   at Microsoft.Adapters.OracleDB.OracleDBConnection.Microsoft.ServiceModel.Channels.Common.IConnection.BuildHandler[TConnectionHandler](MetadataLookup metadataDictionary)
   at Microsoft.ServiceModel.Channels.Common.Design.ConnectionPool.GetConnectionHandler[TConnectionHandler](Guid clientId, TimeSpan timeout, MetadataLookup metadataLookup, String& connectionId)
   at Microsoft.ServiceModel.Channels.Common.Channels.AdapterRequestChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open()

In the stack trace above, we see this program: Microsoft.Adapters.OracleDB.OracleDBConnectionFactory.LoadUdtAssemblies so I believe it gets the error trying to load the .DLL for the UDTs (User Defined Types).

But here is the full situation. This app works fine on BizTalk 2016. I ran GacUtil to put the exact same DLL into the GAC on BizTalk 2020.

From looking at the schemas in the application, the UDTs are in the request, not the response. The BizTalk orchestration is sending multiple rows of data to be inserted or updated.

The send port has the correct .dll name specified in the userAssembliesLoadPath property: C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Oracle_ZEMA_XXCMI_PowerDataUserTypes_v0101\v4.0_0.0.0.0__81552c10a3b36c51\Oracle_ZEMA_XXCMI_PowerDataUserTypes_v0101.dll

I have also created a separate Host Instance for this particular SendPort. Right now I have it set to be 32 bit, but I have tried 64 bit as well.

We one other app that uses a different UDT .dll file, and it is working fine.

I tried to rebuild the .dll using Visual Studio 2019. I went through "Add Generated Items", "Add Adapter Metadata", and used WCF-OracleDB as the adapter. It generated the schemas, but not the .DLL. So that's a second question.

The error does say to "retrieve the LoaderExceptions property". I spent some time today trying to catch a better exception and find that property, but no success. Our catch for System.Exception is firing, and we have code that does this:

 "ExceptionType=" + System.Convert.ToString(exException.GetType()) +

which shows this in our trace:

ExceptionType=Microsoft.XLANGs.Core.XlangSoapException

I added two new catch blocks to my scope shape (above the System.Exception), but neither caught anything, only the System.Exception.

  1. System.Reflection.ReflectionTypeLoadException
  2. Fault from the two-way Send Port Soap 1.1 (didn't try 1.2 yet)

I have checked the InnerExeption and it is null. The exception type is: Microsoft.XLANGs.Core.XlangSoapException. I also tried this:

exBase = exException.GetBaseException(); 
tempExceptionText = tempExceptionText + 
        "\r\nBase ExceptionType=" +  
            System.Convert.ToString(exBase.GetType()); 

But that also shows: Base ExceptionType=Microsoft.XLANGs.Core.XlangSoapException

2

There are 2 best solutions below

0
NealWalters On BEST ANSWER

It turns out that when you generate the UDT (using the Add Generated Items tool in Visual Studio), the .dll generated apparently gets a reference to a specific version of the OracleAccess.dll (or similar .dll). Thus it is not good for different version of Oracle, and it must be regenerated on a server with the desired release of Oracle. (We had to do a Microsoft support ticket to get to this conclusion.)

0
NealWalters On

I think this is the start of the answer, I will add more when concluded.

Based on the @nimmat answer here: How to diagnose Resharper Unit Test Runner "Unable to load one or more of the requested types" error

I created the following PowerShell script to try to re-created the issue:

function GetTypes($path) {
   [Reflection.Assembly]::LoadFile($path) | % {$_.GetTypes()}
   $Error[0].Exception.InnerException.LoaderExceptions
}

cls

Write-Host "-----------LANDMGT-----------"
$path = "c:\Windows\Microsoft.NET\assembly\GAC_MSIL\Oracle_LandMgt_APPS_XXCHEN_LMS_INV_TRX_PKG_v0101\v4.0_0.0.0.0__81552c10a3b36c51\Oracle_LandMgt_APPS_XXCHEN_LMS_INV_TRX_PKG_v0101.dll"
GetTypes($path) 


Write-Host 
Write-host "-----------ZEMA-----------"
$path = "C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Oracle_ZEMA_XXCMI_PowerDataUserTypes_v0101\v4.0_0.0.0.0__81552c10a3b36c51\Oracle_ZEMA_XXCMI_PowerDataUserTypes_v0101.dll"
GetTypes($path) 

I get the same errors with each one, which implies that my test of the LandMgt orchestration(s) might have not run the Oracle logic.

Output:

-----------ZEMA-----------
Exception calling "GetTypes" with "0" argument(s): "Unable to load one or more of the requested types. Retrieve the 
LoaderExceptions property for more information."
At D:\Scripts\TestLoaderExceptions.ps1:3 char:48
+    [Reflection.Assembly]::LoadFile($path) | % {$_.GetTypes()}
+                                                ~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ReflectionTypeLoadException
 
Could not load file or assembly 'Oracle.DataAccess, Version=4.121.1.0, Culture=neutral, 
PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Oracle.DataAccess, Version=4.121.1.0, Culture=neutral, 
PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Oracle.DataAccess, Version=4.121.1.0, Culture=neutral, 
PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Oracle.DataAccess, Version=4.121.1.0, Culture=neutral, 
PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Oracle.DataAccess, Version=4.121.1.0, Culture=neutral, 
PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Oracle.DataAccess, Version=4.121.1.0, Culture=neutral, 
PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Oracle.DataAccess, Version=4.121.1.0, Culture=neutral, 
PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Oracle.DataAccess, Version=4.121.1.0, Culture=neutral, 
PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.

Based on the above, I changed this machine.config (because I'm using a 32-bit host instance): c:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config by adding a second redirect:

but now getting a new error:

Error Description: Microsoft.ServiceModel.Channels.Common.MetadataException: Metadata resolution failed for OperationId: "http://Microsoft.LobServices.OracleDB/2007/03/XXCMI/Procedure/CHN_POWER_FWD_PRICES_SP". ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Oracle.DataAccess.Client.OracleLogicalTransaction..ctor(OracleConnection connection, Byte[] ltxid)
   at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck, Int32 isRecoverable, OracleLogicalTransaction m_OracleLogicalTransaction)
   at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src, OracleLogicalTransaction m_oracleLogicalTransaction)
   at Oracle.DataAccess.Client.OracleConnectionOCP.Open(OracleConnection con)
   at Oracle.DataAccess.Client.OracleConnection.Open()
   at Microsoft.Adapters.OracleCommon.OracleCommonConnectionWrapper..ctor(String connectionString, OracleCommonExecutionHelper executionHelper)
   at Microsoft.Adapters.OracleDB.OracleDBConnection.OpenConnection(OracleCommonExecutionHelper executionHelper)
   --- End of inner exception stack trace ---