The following Powershell function will add all files not yet added, then do a commit with the message provided in the call to the function, then do the push. The prerequisite is that the “GIT” command line is installed and available. I was earlier looking for an API, but I think this is the apparently the best way of accomplishing the commit.

# Tested 01/25/2019 - by adding a test file and running this script 

function GitAddCommitPushDir ($directory, $commitMessage) 
    cd $dirname 
    git add .
    git commit -m $commitMessage
    git push

$dirName = "d:\Git\MyCodeDir"
GitAddCommitPushDir $dirName "Test commit by Powershell Script" 


Full Error

System.InvalidCastException: Failed to convert parameter value from a String to a IEnumerable`1.
—> System.InvalidCastException: Invalid cast from ‘System.String’ to ‘System.Collections.Generic.IEnumerable`1
[[System.Data.Common.DbDataRecord, System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089]]’.
at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType, Boolean& coercedToDataFeed, Boolean& typeChanged, Boolean allowStreaming)
— End of inner exception stack trace —


We use SQL User-Defined-Types to pass XML data from BizTalk to SQL stored procs.
I had to build a custom EDI schema to change the inbound validation for a field.

In this particular project, the EDI pipeline had “Preserve Interchange” set to true.
I knew there was a map in my project on this data, but the map itself used a special little schema that supported the “Preserve Interchange” format.
So I think I might get lucky, and just be able to deploy the schema.

Well – the map used XSLT, and the XSLT had the namespace of the schema.
So although the map ran, it was generating a call to the stored proc that had no data, i.e. the User-Defined-Type didn’t get mapped under the root element.
That caused the odd validation error above!

In Summary – the namespace in the XSLT did not match the namespace specified in the Party/Agreement configuration.  Thus the output of the map had a root element, but none of the User-Defined-Type elements.

The field “FilterBytes” contains the subscription filters for batching. We are converting from 2010 to 2013, and I need the a report of the “source of truth” as to which of our customers goes to which party, so we build the same parties correctly in 2013.

select top 1000 
  p1.Name as PartnerNameA, 
  p2.Name as PartnerNameB, 
  ag.Name as AgreementName,
  bd.Name as BatchDescriptionName,
  --Convert(varchar(max), bd.FilterBytes) as 'ConvertFilterBytes',
  replace(replace(replace(replace(replace(replace(replace(CONVERT(VARCHAR(max), FilterBytes),'','') ,'',''), '',''),'',''),'',''),'',''),'','') as FilterBytesStripped,
  p1.PartnerId as P1_PartnerID,
  p2.PartnerId as P2_PartnerID,
  ps.PartnerAId ,
  from tpm.BatchDescription bd 
  inner join tpm.Agreement ag on ag.ReceiverOnewayAgreementId = bd.OnewayAgreementId 
  inner join tpm.Partnership ps on ps.PartnershipId = ag.PartnershipId 
  inner join tpm.Partner p1 on p1.PartnerId = ps.PartnerAId 
  inner join tpm.Partner p2 on p2.PartnerId = ps.PartnerBID 
  where bd.Protocol = 'x12' 
  order by p1.Name 

The replace functions above remove some of the special characters (but not all of them). Some of those special characters are used as separators between keywords like filterOperator, filterValue, and property and the following value. Sorry if the replace characters don’t come through to the blog; not sure how to easily put them here.
FilterBytes is stored in hex, so you can use the convert to VARCHAR(max) to make it somewhat more readable.

You can take a sample value of FilterBytes and put in NotePad++.
If you split the FilterBytes on the at sign, it looks something like this:

@FilterPredicateO i)
@ statements

Note: Some of the other special characters seem to prevent the find command from working in NotePad++ and even in Powershell. I never stopped to figure that out or research more.

I don’t have access to 2010 prod where I work, so I asked the BizTalk admin to run the above query then save to a CSV. I then wrote a Powershell to do the more difficult work of parsing the filterBytes there. I might be able to share that in the future.

I needed a list of files from a huge directory of file for certain companies, and the company name was the prefix of the filename.

The company names are added to an array of strings.  This script recursively gets all filenames in a given directory, tests them to see if the start with any of the given prefixes, then writes to the console and to a given filename.

$dir = "c:\Integrations\InvoiceOut\FTP\"
$outputFilename = "d:\scripts\selectedFiles.txt"

if (Test-Path $outputFilename)
    #since we are appending to end of file, clean out the file on each run 
    #(or alternative put a date/time in the filename) 
    Remove-Item $outputFilename

$prefixes = @()   #create new empty array 
$prefixes += "test1"
$prefixes += "test2"
$prefixes += "abc"
$prefixes += "def"
#put as many prefixes as you wish here... 

$files = get-childitem -path $dir -recurse -file
foreach ($file in $files)
    $parts = $file.BaseName.Split("_")   #my files were in format prefix_date_other.txt
    if ($prefixes -contains $parts[0])
       Write $file.Name #write to console
       Add-Content -Path $outputFilename $file.Name #write to file

Note: You could also use $file.FullName to get the entire file name including the directory.
$file.BaseName is the file name without the directory and without the extension.
$file.Name is the file name without the directory (but with the extension).

If your filenames don’t have names like mine: CompanyName_text_text_text.txt, then you could do two loops.
One to loop through the prefixes and then to and use the C# string.StartsWith method to see if the file starts with that prefix. (Or instead of a prefix, maybe your search terms could be anywhere in the filename, use the C# string.IndexOf).

#first part would be same as above 

$files = get-childitem -path $dir -recurse -file 
foreach ($file in $files) 
       foreach ($prefix in $prefixes) 
           if ($file.Name.StartsWith($prefix))   
           # or to search anywhere in filename: if ($file.Name.Indexof($prefix) -gt 0) 
                 Write $file.Name  #write to console 
                 #Add-Content -Path $outputFilename $file.Name #write to file 

BTDF deploy on local machine in Visual Studio by using “Tools”, “Deployment Framework for BizTalk”, “Deploy BizTalk Solution” failed with the following error in XmlPreprocess.exe

/s:: Argument expects a parameter

What caused the error for me was that I in the SettingsFileGenerator.xml spreadsheet, I had renamed all the “Settings File Names” for each environment.  I switched the “Local Development” back to Exported_LocalSettings.xml and this got around the issue.

Perhaps there is a setting in the .btdfproj file that allows you to specify (override) the local settings name, but I couldn’t find it today.




When I tried to modify the “Document schemas” (Collection) property on an XML Validation Pipeline Component, I got this error:

I don’t have the total solution, but the problem was that I had an EDI210 standard schema and an EDI210 custom schema.
When the custom schema was added as a reference at the same time as the standard one, then this error occurs on all XML Validation pipeline components in the project. Apparently some properties overlap.

Document namespace is a combination of name and assembly of the schema, separate by a comma (and a space).

Step-1. To find this you need to go to BizTalk Admin console then navigate to the application where you have deployed your schema DLL. Click on the Schemas (in the tree structure on the left) to list all schemas. Sort them as needed to find your schema. (It has to be deployed for this to work.)

Step-2. Double click on the schema for which you want the Document Spec Name; you will find “General” tab on the left hand side of the window.

Step-3. On this General tab, “Name”, “Assembly” and “Type” would be listed, read-only, but you can copy-paste from them.

Step 4 – Open NotePad++ or your favorite editor,
a) copy the value from “Name”,
b) type a comma followed by a space
c) copy the value from “Assembly”

Example from above:

Name: DemoSchema.Sample1
Assembly: DemoSchema, Version=, Culture=neutral, PublicKeyToken=984c0907a0e7fc84

Thus, the created document spec name would be:
DemoSchema.Sample1, DemoSchema, Version=, Culture=neutral, PublicKeyToken=984c0907a0e7fc84

Above steps taken from and elaborated a little.

NOTE: You can also get the Target Namespace from this screen.
If you want to filter on a message by MessageType, use the pattern namespace#rootElement.

Log4Net allows you to customize your output files with various parameters.

For example:

<conversionPattern value="%property{logLocation}\Logs\MyProgram.log.%date{yyyyMMdd-HHmm} processid[%processid]  job[%property{jobType}].txt" />

It will show something like “job[LoadJob]” or “job[Whatever] based on your custom property called “jobType”.

This is a custom property which is set as follows.

GlobalContext.Properties["jobType"] = currentProcessorType;  // or some literal value 

Error when running from BizTalk run time environment: Exception from HRESULT: 0x80131942
(no other details were provided)

Exact error when running “Test Map” in Visual Studio: Does not contain a matching ‘GetTimestamp’ method that has 0 parameter(s).

I was transferring a BizTalk map from 2010 to 2013.

There was an XSLT inline that had the following:

<xsl:variable name="timeStamp" select="userCSharp:GetTimestamp()"/>

and had this C# function:

<ScripterCode><Script Language="CSharp">
<![CDATA[public string GetTimeStamp()
DateTime date = DateTime.Now;
return date.ToString("HH:mm");

It turns out in my particular case, the function name didn’t actually match, the “s” of “GetTimeStamp” either needed to be capitalized or lower case in both places where it is used.

This blog also shows how to get the time within an XSLT function (in a BizTalk map).

When importing bindings into an application, you might get this error:
Failed to update binding information (mscorlib):
Additional Information
BizTalk Import Bindings Error: Object reference not set to an instance of an object. (Microsoft.BizTalk.ExplorerOM)

While there maybe multiple reasons for this error, here’s the one I found.

The map I was referencing in a Receive Port existed, but it was in a different solution. (I had a typo in the application name when I deployed it). I either move the map from one application to another, or delete it and re-deploy it with the correctly spelled name. Then it worked fine.