No offense, but, actually, the conclusions of your co-worker about how something he thinks should work doesn't make it the "official way" it should work. For that, we refer to the OGC specifications.
You can download the OpenGIS Simple Features Specification for SQL 1.1 from the OGC website (a bit older) or even better, the newer OpenGIS Implementation Specification for Geographic information - Simple feature access - Common architecture 1.2.1. Either one would work.
If you refer to pages 66-70 you will find the specification for the older document, or pages 65- 72 for the newer specification.
To sum it off, there is no part that prohibits the wkb from having trailing data. In fact, the specification includes counters for every single element so you know exactly how much of the binary blob you should be parsing. It goes down to even including a byte for byte ordering so you can switch between endianness of the binary representation of every inner geometry element as you parse it!
My point is you always know exactly how much of it you should be reading and how you should be interpreting it.
Microsoft has chosen, in their parser, to continue consuming the binary content even though nothing in the OGC specification says it should. Then they chose to consider that condition "invalid". Are they wrong? Well, that is how they interpreted it even though the binary blob itself does satisfy the spec.
Saying the WKB provided by ESRI is "invalid", for this particular case, is incorrect.
By the way, every single other WKB parser out there (GEOS', PostGIS', GDAL's, ESRI's, SharpMap's, Autodesk's, etc) accepts this condition as OK.
Here is your example using PostGIS:
mydb=# select st_astext('010200000009000000BA854FAC7A273541B2325A112E643341B6FB21797E273541F080DDD356643341C87DB90187273541DA6E0FE4776433410692AC108B27354140AF88AF81643341CD1A8D1FA127354163B43190B9643341486A0F7CDF2735415B63352B7065334146AFE4D2E12735411BC18BCB776533413DA83565EC273541C03198AA9E653341861DA529F02735414B65EE25C46533410000000000');
st_astext
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
LINESTRING(1386362.67308842 1270830.06778256,1386366.47317479 1270870.82759863,1386375.00673662 1270903.89086049,1386379.06513322 1270913.68567939,1386401.12324684 1270969.56325843,1386463.48461022 1271152.16878339,1386465.82380195 1271159.79510123,1386476.39534999 1271198.6663848,1386480.16267571 1271236.14816888)
(1 row)
mydb=#
Now I am going to add any random binary data at the end of your geometry:
mydb=# select st_astext('010200000009000000BA854FAC7A273541B2325A112E643341B6FB21797E273541F080DDD356643341C87DB90187273541DA6E0FE4776433410692AC108B27354140AF88AF81643341CD1A8D1FA127354163B43190B9643341486A0F7CDF2735415B63352B7065334146AFE4D2E12735411BC18BCB776533413DA83565EC273541C03198AA9E653341861DA529F02735414B65EE25C46533411010101010101010101010101010101010101010101fff01010101fff');
st_astext
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
LINESTRING(1386362.67308842 1270830.06778256,1386366.47317479 1270870.82759863,1386375.00673662 1270903.89086049,1386379.06513322 1270913.68567939,1386401.12324684 1270969.56325843,1386463.48461022 1271152.16878339,1386465.82380195 1271159.79510123,1386476.39534999 1271198.6663848,1386480.16267571 1271236.14816888)
(1 row)
mydb=
Still works.
The bug is actually in the Microsoft parser.
Best Answer
Using the IWkb interface does a nice job at converting between an IGeometry and WKB. From a WKB you can use the Microsoft.SqlServer.Types library to convert a WKB to SqlGeometry then back to WKT.
At this point you have the WKB stored in wkb_bytes. If you want to go the next step to SqlGeometry then to WKT: