MIIS出现“stopped-file-embedded-nulls”错误的处理

转帖:extensible MA import drops spaces causes import error - TechNet Forums

今天在试验MIIS时出现了“stopped-file-embedded-nulls”的错误,在网上查询了一下,原来是编码的问题。

Hello Paul!

I have found that when I write Extensible MA's that the formatting need be exactly correct or you can run into issues that cause the import not to run successfully

Since, throwing the Encoding.Unicode into the overload made sense, I used this call once to init my StreamWriter:

Code Snippet

StreamWriter sw = new StreamWriter(strFilePath, true,Encoding.Unicode)

and I was receiving "stopped-file-embedded-nulls" errors on import.  I looked in the file and I couldn't tell what was going on.  I made sure there were no trailing carriage returns or no trailing spaces.  I even tried to parse out all of the nulls:

Code Snippet

szCSVString.Replace('\u0000', '\u0020')

I haven't figured out what fixed the issue, whether it be the string replacement for nulls, modifying the streamwriter or removing the last carriage return, but it finally started working when I took the Encoding overload out of the StreamWriter:

Code Snippet

StreamWriter sw = new StreamWriter(strFilePath, true)

The moral of the story, MIIS is super sensitive with regards to data type importing.  If you need trailing spaces on import or export, I would find a Unicode character to replace the space that you know you're not going to use.  For my testing, I use a tilde (~).  I would then specify to look for the trailing spaces on the way in and the tilde on the way out of the Extensible MA. 

Let us know how it goes.

--Shawn

上面是源文。

我检查了代码中使用生成文件的编码格式是:System.Text.Encoding.Unicode

MA设置的编码是其它编码,现在 修改成System.Text.Encoding.Unicode后,问题解决。

posted @ 2008-11-27 16:53  cdboy  阅读(351)  评论(0编辑  收藏  举报