Using code like:
...
EdiMessage ediMessage = (EdiMessage)instance;
using (FileStream ediStream = File.OpenWrite(file))
{
using (EdifactWriter writer = new EdifactWriter(ediStream))
{
writer.Write(ediMessage);
}
}
I receive an error message 'No interchange was started.'
Stack trace below the writer.Write call (last public version of Edifabric):
at EdiFabric.Framework.Writers.EdiWriter`2.Write(EdiMessage message)
It concerns a D96A INVOIC object with BGM, some FTX and a UNH. The object class is . And the exception is raised by EdiWriter on the call writer.Write
.
The ediMessage
contents seem valid. According to Edifabric documentation it should add the default EDIFACT separators automatically:
If not explicitly specified the writer will use the default separators per standard:
What did I forget to setup?
It seems a documentation bug; the defaulting does not happen. When changing the code to:
the unb inserts a header in the document after which in this case one message is added. The code now raised an "Object reference not set to an instance of an object." with call stack
which was fixed by adding: