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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 28.10.2006, 16:40   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
Dynamics AX: Make use of DotNet Assemblies from DAX 4.0
Источник: http://dynamics-ax.blogspot.com/2006...-from-dax.html
==============
As part of my AIF series of post, I thought that it would only be right to prepend and post about how to make native .Net assembly calls from DAX 4.0 X++ code.

This is a great addition to DAX, being able to take given .Net assemblies and create objects from classes, and make use of .Net code through native references and X++ code, rather than through COM.
With that said, let's jumpe right in and Talk about what it takes to make use of a .Net assembly from within Dynamics AX 4.0.

(1) First the given .Net assembly must be a signed one. Meaning that it must have a public token associated with it.
(2) Second the assembly needs to be installed into the GAC

Once you are for sure these two are done next is creating a reference within DAX. From the AOT you can go to close to the bottom and you will see references. From there right click and add a reference. The reference form will pop up and you will have to click on the browse button and select your .DLL .Net Assembly.

Once the reference is made, then you can move on to creating code that makes use of the given .Net assembly. I say start with a new job. ONce you have the new job created, add code that looks similar to this:

static void DotNetIntegration(Args _args)

{

DotNetAssembly.DNClass DNC;
str s;
CLRObject clrDNC;
;


clrDNC = new DotNetAssembly.DNClass();
DNC = clrDNC;
s = DNC.DNMethod("Test");
info(strfmt("%1",s));
}

Now to speak a little bit about this code. The first line DotNetAssembly.DNClass DNC; Is a declaration that makes use of the Referenced Assembly, and one of it's exposed classes. Next we have a standard str s declaration, and then what makes the interaction possible, the CLRObject declaration.

From there we move on to the execution of code, which shows the following line first: clrDNC = new DotNetAssembly.DNClass(); This line is very important, in that it creates a new instance of the clrDNC CLRObject class. What you have to realize at this point is that all .Net Assembly Classes are CLRObjects, and therefore must be created as so. Notice the next line is we set the newly created clrDNC object and make the DNC object equal to that. By doing this we get the look ahead ability to view the methods within the .Net assembly, for example the line of code: s = DNC.DNMethod("Test");

So you can take any .Net assembly, make sure the assembly is signed and installed into the GAC, and then make use of the CLRObjects you can interact with Dot Net with native X++ calls, without having to make use of COM.

Check back soon for more!

Find a job at: www.DynamicsAXJobs.com


==============
Источник: http://dynamics-ax.blogspot.com/2006...-from-dax.html
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Dynamics AX: Managing Your Supply Chain Using Microsoft Dynamics AX 2009 - Book Review Blog bot DAX Blogs 0 31.03.2009 23:06
Dynamics AX: Microsoft's strategy and vision for Dynamics AX and SOA Blog bot DAX Blogs 0 05.03.2009 18:05
axStart: Microsoft Dynamics AX 2009 Hot Topics Web Seminar Series Blog bot DAX Blogs 0 06.08.2008 12:05
Inside Dynamics AX 4.0: Usage Scenarios Blog bot DAX Blogs 0 04.10.2007 05:15
Dynamics AX: Why Dynamics AX beats SAP Blog bot DAX Blogs 0 10.01.2007 23:15

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

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

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