Question

I need to call a method in an external assembly from a scripting functoid in a BizTalk map, in particular a Enumerated type is a parameter in a C# assembly. Is this even possible? I have passed in strings or integers while calling external assemblies many times with no problems.

Was it helpful?

Solution

Unfortunately, you cannot use enumerated types in methods designed to be called from the scripting functoid. However, you can nearly achieve what you want by creating a wrapper around the external method.

For instance, the following method cannot be called directly from a scripting functoid.

using System;

namespace ExternalAssembly
{
    public enum Options
    {
        OptionNumberOne,
        OptionNumberTwo,
    }

    public class Helper
    {
        public string DoSomething(Options option)
        {
            // really do something useful here
            return String.Empty;
        }
    }
}

Attempting to use this method will result in the following error:

Function 'ScriptNS0:DoSomething()' has failed. Value was either too large or too small for an Int32.

However, if you write the following wrapper method, if works:

    public string DoSomething(string option)
    {
        return Helper.DoSomething(
              (Options) Enum.Parse(typeof(Options), option)
            );
    }

Notice that the wrapper method is using a regular String parameter, instead of the original Options enumerated type. If you have the source code for the method you want to call, just add this extra wrapper as and overload and you're done.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top