Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Problem with Script Functoid in Biztalk map
- This topic has 2 replies, 1 voice, and was last updated 9 years, 2 months ago by
community-content.
-
AuthorPosts
-
-
June 11, 2008 at 9:07 AM #19897
Hi all,
I am having trouble when testing a map in Biztalk, it gives me an error message pointing to an external C# assembly calling a public static method in a class:
XSL transform error: Function ‘ScriptNS0:PadString()’ has failed. Cannot widen from target type to primitive type.
The code for the method is the following:
namespace BMCHP.Objects
{
…public static string PadString(string strInput, int lenField, bool bDirection, string strPadIndicator)
{
int strLen = strInput.Length;
string strRet;
char chrPad;
try
{
if (lenField > strLen)
{
if (strPadIndicator == “zero”)
{
chrPad = ‘0’;
}
else
{
chrPad = ‘ ‘;
}
if (bDirection)
{
strRet = strInput.PadLeft(lenField – strLen, chrPad);
}
else
{
strRet = strInput.PadRight(lenField – strLen, chrPad);
}
}
else
strRet = strInput;
}
catch (ArgumentException e)
{
Console.WriteLine(“Argument exception in PadString function: ” + e.Message);
return “”;
}
return strRet;
}
…
}I configured the functoid inputs with the following parameters (in order) to match the sequence of parameters passed to the C# method:
– Scripting functoid (conversion function that takes an integer and converts it to a string; the input is an iteration functoid and the output is linked to this functoid)
– Constant value of “7”
– Output of an “Equal” logical functoid (that compares two identical values)
– Constant value of “zero”
As far as the C# assembly goes, after compiling it in its own project, I referenced it in my Biztalk project, and installed the DLL in the GAC, using the gacutil program for .NET 1.1 framework.
Btw, I should also mention that I have both .NET 1.1 and 2.0 frameworks installed on the same workstation (Windows XP Professional 2003), and the C# assembly was built using VS 2003 (.NET 1.1).
-
June 11, 2008 at 10:54 AM #19898
Sorry, I don’t have an answer, but are you able to unit-test your static method from a C# harness? Just want to isolate whether it’s Biztalk or parms that you are passing that is causing the error. I did a google on “cannot widen from target type to primitive type”, and found quite a few hits.
Neal
-
June 11, 2008 at 12:07 PM #19900
Hi Neal:
Thanks for the reply. I stopped referencing the external assembly method in the script functoid and brought the code back into an inline C# function, as I was getting a similar error with another method when testing the map. I also reworked the code by hard-coding the padding character into the PadLeft and PadRight string methods, and this resolved the error.
Cheers,
Daniel.
-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.