“I am feeling privileged to write a blog on an issue which troubled me on one of my favorite topics “MAP” in BizTalk.  If you face the same issue and my resolution does not help, please drop a comment and I will try to help you in troubleshooting depending on my availability and bandwidth.”

Recently I was working on a BizTalk map issue, in which I was getting the below error:

Event Type:   Error
Event Source: MyApp
Event Category:      None
Event ID:     0
Date:         12/14/2011
Time:         3:13:03 PM
User:         N/A
Computer:     MyServer

Description:
Exception: In MyApp.odx ---> Message:[Error encountered while executing the transform MyApp. mapInvoic. Error:Unable to create the transform..];
Source:[Microsoft.XLANGs.Engine];
StackTrace:[   at Microsoft.XLANGs.Core.Service.ApplyTransform(Type mapRef, Object[] outParams, Object[] inParams)
   at MYApp.Orchestrations.myOrch.segment2(StopConditions stopOn)
   at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)];
InnerException:[System.ArgumentNullException: Value cannot be null.

Parameter name: extension

   at System.Xml.Xsl.XsltArgumentList.AddExtensionObject(String namespaceUri, Object extension)
   at Microsoft.XLANGs.BaseTypes.TransformBase.get_TransformArgs()
   at Microsoft.XLANGs.RuntimeTypes.TransformMetaData..ctor(Type transformBaseType)
   at Microsoft.XLANGs.RuntimeTypes.TransformMetaData._creator(Type t)
   at Microsoft.XLANGs.RuntimeTypes.MetadataCache._slowFor(Type t)
   at Microsoft.XLANGs.RuntimeTypes.MetadataCache.For(Type t)
   at Microsoft.XLANGs.RuntimeTypes.TransformMetaData.For(Type t)
   at Microsoft.XLANGs.Core.Service.ApplyTransform(Type mapRef, Object[] outParams, Object[] inParams)];

For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.

The pain was the application was getting the executed successfully in my development environment :) (as happen with most of the developer) but failing in the QA environment.

Application Details:

File based receive Port -> Orchestration(consisting of Map) -> File based Send Port.

 Troubleshooting Steps:

1)      I tested the failed file in my dev environment and as expected it worked without any issue.
2)      I created a Receive Send port pair in admin console in QA( to isolate the issue). Used the map at the receive port and dropped the same file. This time I got the different error.

A message received by adapter "FILE" on receive location "Receive Location2" with URI "MyServer\Map Error\I\*.xml" is suspended.

 Error details: Object reference not set to an instance of an object. 
 MessageId:  {75731D85-BFC2-4356-8F24-CC1135A107A6}
 InstanceID: {8DF62EAD-23FA-4792-9601-6DF92B721C1A}
 

I was surprised to see this error :( as this is completely different from the main issue.

3)      I tested the same file in Visual Studio by doing the test map. I got the same error which I was getting at run time. This was the snippet of the OutPut of test map. 

\\MyServer\BizTalkTesting\mapInvoic.btm : error btm1010: The "Scripting" functoid has 1 input parameter(s), but 0 parameter(s) are expected.
\\MyServer\BizTalkTesting\mapInvoic.btm:  error btm1010: The "Scripting" functoid has 1 input parameter(s), but 0 parameter(s) are expected.
\\MyServer\BizTalkTesting\mapInvoic.btm : error btm1010: The "Scripting" functoid has 1 input parameter(s), but 0 parameter(s) are expected.
\\MyServer\BizTalkTesting\mapInvoic.btm: error btm1010: The "Scripting" functoid has 1 input parameter(s), but 0 parameter(s) are expected.
TestMap used the following file: <file:///\ \\MyServer\BizTalkTesting\0000023672_16130380.xml> as input to the map.
\\MyServer\BizTalkTesting\mapInvoic.btm: error btm1050: XSL transform error: Unable to write output instance to the following <file:///C:\Users\MyServer\AppData\Local\Temp\_MapData\BizTalkTesting\ mapInvoic _output.xml>. Value cannot be null.

Parameter name: extension

Test Map failure for map file <file\\MyServer\BizTalkTesting\mapInvoic.btm >. The output is stored in the following file: file:///C:\Users\MyServer\AppData\Local\Temp\_MapData\BizTalkTesting\mapInvoic_output.xml
Component invocation succeeded.

4)      I thought to make use of the Debug Map option(though I do not know how to debug xslt :( ), I started Debugging the map and got an error which was more clear

Cannot find a script or an extension object associated with namespace 'http://schemas.microsoft.com/BizTalk/2003/ScriptNS0'.

The line of Map on which it was failing was pointing to the function name(MyFunction) of my class library.
Now I got the hint, that it is something to do with the dll mismatch which developer is famous to do.( As a general fact, everything works on development environment :) )
I went to the QA machine open the dll which I was using in the map as an external assembly to scripting functoid. I compared the date time stamp for the dll in both environments. TO my luck it was different.
Without any further delay, I took the dll from the GAC of the Dev machine and put it on the QA machine GAC. Tested the same file and it worked.
For my curiosity I used the reflector to get the code for both version of dll, and as expected MyFunction was not there in the dll of the QA environment.

Lesson Learnt:

1)      For any mapping issue, use Visual Studio Test Map And Debug Map to get the exact error.
2)      If we use external assembly in the scripting fucntiod MAP create an Extension Object file to keep the Details of the dl being referenced in the scripting functoid.

The snippet of the xml file will be like this and you will get this file if you do validate Map in the Visual Studio.

<ExtensionObjects>
  <ExtensionObject Namespace="http://schemas.microsoft.com/BizTalk/2003/ScriptNS0" AssemblyName="Library, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" ClassName="Library.Data" />
  <ExtensionObject Namespace="http://schemas.microsoft.com/BizTalk/2003/ScriptNS1" AssemblyName="Microsoft.BizTalk.BaseFunctoids, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" ClassName="Microsoft.BizTalk.BaseFunctoids.FunctoidScripts" />
  </ExtensionObjects>

Written by:        
Deepak Sanghi

Reviewed By:
Shailesh Agre

Microsoft GTSC.