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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 07.02.2019, 06:17   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
erconsult: SysExtension framework pitfall: avoid new()
Источник: http://erconsult.eu/blog/sysextensio...ework-pitfall/
==============

This research has been inspired by a real bug in the D365FO v. 10 (preview) application. It turned out that the SysExtentionAppClassFactory doesn’t explicitly call the new() method the 2nd time when it takes a previously resolved class name from the cache.

This is just good enough to pass an automated test or to fool a lazy tester, but in real life this may potentially result in run-time errors or other misbehaviour. Any code, any internal variable initialization you placed in the new() constructor is going to be bypassed the second time you call the same operation within the same client session.

To illustrate this, let’s use the demo project from my other blog.

Add the following code into the new() method of the MealCourse class:
abstract public class MealCourse
{
...
protected void new()
{
info ("Yummy!");
}
}

Create a new action menu item to call this class, and place it on any of the D365FO menus. Call it once:

Right, yummy-yummy-yummy!

Call it again from in the same window (do not reload the browser but just click the menu item the 2nd time):

Nothing. The new() method has not been called.

Conclusion

Do not rely on the new() method when using the SysExtension framework. Let it be empty, do not put any logic at all inside. Perform the variable initialization in a dedicated method or any of the parm() methods, and call them explicitly in your constructor right after the SysExtensionAppClassFactory ::getClassFromSysAttribute() call.

The post SysExtension framework pitfall: avoid new() appeared first on ER-Consult.



Источник: http://erconsult.eu/blog/sysextensio...ework-pitfall/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
jaestevan: Embrace the extensions mindset with Dynamics 365 for Finance and Operations #2 – SysExtension framework [EN] Blog bot DAX Blogs 0 24.06.2018 23:13
jaestevan: Embrace the extensions mindset with Dynamics 365 for Finance and Operations #2 – SysExtension framework [EN] Blog bot DAX Blogs 0 14.06.2018 14:14
mfp: SysExtension Framework – to the rescue Blog bot DAX Blogs 26 14.12.2015 14:02
german_nav_developer: Buildnummern-Übersicht Microsoft Dynamics NAV 2009 SP1 Blog bot Dynamics CRM: Blogs 0 11.06.2010 16:33
german_nav_developer: Buildnummern-Übersicht Microsoft Dynamics NAV 2009 Blog bot Dynamics CRM: Blogs 0 04.06.2010 13:21
Опции темы Поиск в этой теме
Поиск в этой теме:

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

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

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

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