AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 24.01.2016, 15:19   #1  
Blog bot is offline
Blog bot
Участник
 
14,567 / 630 (51) +++++++
Регистрация: 28.10.2006
Axilicious:CombineXpos.exe Length cannot be less than zero
Источник: http://www.ksaelen.be/wordpresses/dy...ess-than-zero/
==============

When I was using the combineXPOs.exe executable the other day on a new project, I ran into an issue. The error message thrown by the tool was the following:



CombineXPOs.exe : Warning [-5] CombineXPOs.exe : Error [] Length cannot be less than zero.



I remembered that Martin Dráb ran into the same error previously so I went to take a look at his blog post on this type of error. In his post, he explains this might be because of empty / corrupted XPO files and indeed, this error pops up when you either have an empty XPO file or a (corrupted) shared project node that contains no objects.


Removing 2 of 6000+ XPO files that turned out to be empty indeed helped and the tool got further in the list of XPO files. But wait, it still gave the same error message?! So what was different here? I saw that the error code being returned was not -4, but -5. And I did not have empty XPO files anymore. And on top of that, now it was the directory with all the Shared Project XPO files that returned errors.

I couldn’t see right away what the issue was here, so I decided to peek into the executable and reverse engineer a C# project out of it. The I stepped through the process of combining a single file and managed to see what was going on. Somewhere inside there, there is an XPOReader class that opens the XPO files and looks at the encoding of the files.


X++:
if (fileStream.Length > 3L &&(int)numArray[0] == 239 && ((int)numArray[1] == 187 && (int)numArray[2] == 191))
{
    this.fileEncoding = (Encoding)this.utf8Encoding;
    num1 = 1;
}
else
{
    this.fileEncoding = Encoding.GetEncoding(1252);
}
Looking at the code, it turns out that it looks for UTF8 files, and if that is not the case, assumes it has to be CP1252 (Latin 1). What if my files have another encoding? And looking at the files, they turned out to be LCS-2 LE BOM. Until now, I haven’t looked into it why these project XPO files have a different encoding. To solve the issue in this case, a bit of additional code makes sure the XPO reader can correctly read the XPO through codepage 1200.


X++:
if (fileStream.Length > 3L && (int)numArray[0] == 239 && ((int)numArray[1] == 187 && (int)numArray[2] == 191))
{
    this.fileEncoding = (Encoding)this.utf8Encoding;
    num1 = 1;
}
else
{
    // KeSae : Check for codepage UCS-2 LE
    if (numArray[0] == 0xFF && numArray[1] == 0xFE)
    {
        this.fileEncoding = Encoding.GetEncoding(1200);
    }
    else
    {
        this.fileEncoding = Encoding.GetEncoding(1252);
    }
}
Rebuilding the project resulted in a customized CombineXPOs.exe executable that correctly handles the shared project nodes in



Источник: http://www.ksaelen.be/wordpresses/dy...ess-than-zero/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.

Последний раз редактировалось mazzy; 25.01.2016 в 16:27.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
X++: AxBuild.exe for Faster Full Compile of X++ Blog bot DAX Blogs 17 28.04.2014 22:17
Axilicious:Cleaning up after AxBuild.exe Blog bot DAX Blogs 0 15.11.2013 00:12
axtools: CombineXPOs - new version - official beta has started Blog bot DAX Blogs 0 30.06.2012 02:24
X++: New Option to Log X++ Max-Length String Truncation Blog bot DAX Blogs 0 07.10.2011 04:12
emeadaxsupport: AxUpdatePortal.exe does not update Enterprise Portal when not running from an elevated command prompt Blog bot DAX Blogs 0 26.07.2009 15:07
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 20:09.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.