BizTalk Custom Adapter Issue: Adapter error : Value cannot be null. parameter name : stream

When we are new to create custom adapter in BizTalk. Then this issue is really irritated a lot. And it’s not easy to find out what is the real issue.

Adapter error : Value cannot be null. parameter name : stream


It is quite simple to get rid from this issue.

When we define below function to get the Receive and Transmit xsd information in Send Port.

public string GetConfigSchema(ConfigType type)
switch (type)
case ConfigType.ReceiveHandler:
return LocalizeSchema(GetResource(“ClassNamespace.ReceiveHandler.xsd”), resourceManager);

            case ConfigType.ReceiveLocation:
                return LocalizeSchema(GetResource("ClassNamespace.ReceiveLocation.xsd"), resourceManager);

            case ConfigType.TransmitHandler:
                return LocalizeSchema(GetResource("ClassNamespace.TransmitHandler.xsd"), resourceManager);

            case ConfigType.TransmitLocation:
                return LocalizeSchema(GetResource("ClassNamespace.TransmitLocation.xsd"), resourceManager);

                return null;

This location is read from the AdapterManagement from assembly from below function.

Apply System.Diagnostics.EventLog.WriteEntry to check that AdapterManagement will able receive the data in stream or not.

private string GetResource(string resource)
System.Diagnostics.EventLog.WriteEntry(“CustomAdapter”, resource);
string value = null;
if (null != resource)
Assembly assem = this.GetType().Assembly;
System.Diagnostics.EventLog.WriteEntry(” CustomAdapter “, assem.FullName);
Stream stream = assem.GetManifestResourceStream(resource);
StreamReader reader = null;
stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource);
using (reader = new StreamReader(stream))
value = reader.ReadToEnd();

           // System.Diagnostics.EventLog.WriteEntry("CustomAdapter", value);

        return value;

if AdapterManagement will not able receive the data in stream, then modify the .xsd location in GetConfigSchema function as per solution as below:

LocalizeSchema(GetResource(“<Assembly Namespace>.<FolderName(if defined in solution)>.<Name of .xsd e.g. ReceiveLocation.xsd or TransmitLocation.xsd >”)

e.g. LocalizeSchema(GetResource(“ClassNamespace.ReceiveLocation.xsd”)

Hope this will solve the issue. and Remove System.Diagnostics.EventLog.WriteEntry after finding solution

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s