BizTalk Unit Testing issue from .NET 4.0 and above

PipelineObjects.dll is a pipeline tool provided with BizTalk SDK to perform BizTalk Unit testing. The first thing that we do when using this utility is to create an instance of pipelinefactory and create pipeline using the below code.
I used this below code to test my biztalk 2006 applications and everything worked fine as expected.

PipelineFactory pf = new PipelineFactory();
IPipeline pipeline = pf.CreatePipelineFromType(typeof(pipelineClass));

But when I used the same code in BizTalk 2010 environment I encountered the error

“Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.BizTalk.Component.Interop.IComponentTypeInfo'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{CF0480A5-F484-415b-AEC6-0AB44855758B}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))”

However the pipeline that I used in worked as expected in biztalk runtime.

Later found that, from .net 4.0 onwards there has been a change in how .net calls the com component and now on, .net supports calling of com components using an entry in config file. This is the same entry that Biztalk exe(Btsntsvc.exe) uses to executes com components.

 <startup useLegacyV2RuntimeActivationPolicy="true">
 <supportedRuntime version="v4.0" />

After adding the above config file for my unit testing application, my application ran successfully.

Happy Biztalking

Written by
Shashidharan Krishnan

Reviewed by
Jainath V R

Microsoft India GTSC

Comments (3)

  1. Sandeep says:

    In my case even after adding app.config file I am getting the same error. Any suggestions…?

  2. Sandesh S says:

    Hi Sandeep,

    I'm also getting same issue though adding entry in app.config file. Do you able to solve this issue?

  3. Sandesh Sahane says:

    I also encounter this issue but I had to add

    <startup useLegacyV2RuntimeActivationPolicy="true">

    to some other places also.

    Refer post:…/fixing-biztalk-2013-pipeline-unit-tests-avoiding-the-system-badimageformatexception-error

Skip to main content