[转]Dynamics AX and Generic collections of .Net

转自:http://blogs.msdn.com/b/emeadaxsupport/archive/2009/04/23/dynamics-ax-and-generic-collections-of-net.aspx

EMEADAXSupport

23 Apr 2009 9:54 AM

I‘m using Dynamics AX 2009 and want to instantiate the .NET class "System.Collections.Generic.List" in X++.

Intellisense expands the class to "System.Collections.Generic.List`1" however the code cannot be compiled as the class as well as all other classes in the "System.Collections.Generic" namespace are not accepted.

Actually this type as well as every type defined in the namespace System.Collections.Generic are no regular types (are classes) but they are so called "Generics". You can see this for example when you are using a Generic in C#, where you have to specify the type of the Generic at declaration / definition (here the for example for string):

System.Collections.Generic.List<string> list;

More information about .NET Generics can be found here:
Generics (C# Programming Guide)

For Dynamics AX 4.0 Generics are not supported by the X++ language. This is outlined in the Microsoft Press book "Inside Dynamics AX" on page 111: The following feature of CLR cannot be used with X++:

  • Public fields (These can be accessed by using CLR reflection classes.)
  • Events and delegates
  • The ref parameter modifier
  • The out parameter modifier
  • Generics
  • Inner classes
  • The Container composite type
  • The Array composite type
  • Namespace declarations

Besides the "swapping" of the Generic collection into an own Assembly that is referenced back in to Dynamics AX, the only recommendation is to use the Non-Generic counterpart of the collection (see table below).

Generic   Non-Generic
System.Collections.Generic   System.Collections
Collection<T>   CollectionBase
Comparer<T>   Comparer
Dictionary<K, V>   Hashtable
List<T>   ArrayList
Queue<T>   Queue
SortedDictionary<K, V>   SortedList
Stack<T>   Stack
ReadOnlyCollection<T>   ReadOnlyCollectionBase

So in our case the Non-Generic counterpart of "System.Collection.Generic.List<T>" would be "System.Collections.ArrayList".

--author: Alexander Lachner
--editor: Alexander Lachner
--date: 23/04/2009

[转]Dynamics AX and Generic collections of .Net

时间: 2024-11-01 13:28:32

[转]Dynamics AX and Generic collections of .Net的相关文章

Understanding the Settlement Mechanism in Microsoft Dynamics AX

see more at http://blog.mohamedaamer.com/microsoft-dynamics/understanding-the-settlement-mechanism-in-microsoft-dynamics-ax/ Settlement is an accounting transaction that occurs on accounts payable, accounts receivables, and general ledger. This trans

Dynamics AX 2012 – Batch Jobs Not Executing

In Dynamics AX 2012, there are times when batch jobs appear to be stranded in a waiting status.  When this happens, the cause can typically be a batch server or batch group which is not set up properly.   However, if these are set up correctly and yo

微软 Dynamics AX 学习步骤

第一步:了解到AX的架构,AOT结构,了解AOT中表,窗体,类,job,菜单,菜单项的基础开发.知道代码可以写在那里,每个对象以及对象内部的具体设置.如果你不了解类,继承,这些,那么就需要找一下讲述类特性的书籍了.第二步:编写代码.不要觉得自己看了书就完了.还是得按照书上的代码一行一行自己敲出来.然后去想每句代码的含义.可能这样会很慢,但是我想如果能这样坚持十几天,后面就会变得很快甚至不需要看也可以.这里千万不能图快,欲速则不达.第三步:了解系统业务的操作,比如采购业务,销售业务,生产业务.然后

【DataStructure】The description of generic collections

In this blog, generic collections will be talked about  in details.  In the past bacause of shortage of generic argument,  less importance has been attached to the this module. Just now after reading the chapter about this knowledge, I gradually real

Dynamics AX R2 安装Reporting Services 扩展

    今天Reinhard在VS中部署SSRS报表时,接到以下错误: 部署因错误而被取消.在报表服务器上,验证:-SQL Server Reporting Services 服务是否正在运行.     接着,Reinhard进入到AX中,检查系统的报表服务器配置是否正确.不知道怎么配置的同学可以查看Reinhard之前的博文 Dynamics AX 2012 R2 配置报表服务器  .检查发现,报表服务器中的配置也正确.Reinhard点击了一下 验证设置 按钮,收到以下错误: 无法连接到位于

Dynamics AX 2012 R3 Demo 安装与配置 - 导入测试数据 (Step 4)

    在前面三节中,Reinhard分别讲解了如何配置安装环境,安装数据库服务器,AOS和客户端,安装后的编译和配置.如果一直跟随Reinhard的脚步,到这里,已经拥有一个没有数据的系统.     本节,Reinhard将要讲解怎样导入微软提供的测试数据.     首先,将AOS服务停止运行.进入计算机管理,服务,选中AOS服务,右键点击停止.稍等片刻,AOS服务已经停止运行.     接着,Reinhard要将当前空数据库进行备份,避免因导入测试数据失败造成的损失.     进入数据库管理

Dynamics AX 2012 - Report labels does not show up in report

Sometimes the report labels do not show in reports or the report shows label IDs like [email protected] instead of label values. There are two reasons to this type of issues: You have moved your AX service account from AX domain account from AX domai

Changes in Microsoft Dynamics AX 2012 InventTrans data model

The purpose of this post is to give an overview about the changes been made in the Dynamics AX 2012 data model related to inventory transactions. Before AX2012, the only table used for recording all the inventory transactions was InventTrans.  In AX2

Dynamics AX R2 业务系列-采购业务流程

    在博文Dynamics AX R2 业务系列中,Reinhard对这个系列做了一个规划,下面我们就按照规划开始说业务吧.     国际惯例,从采购开始. 1.采购的主要职责     简单点说,采购的主要职责,是从供应商那里获取原料,以保证企业生产.运营.     全面点说,采购的主要职责,是保质保量.适时适价地为企业生产和运营提供原料.保质,主要是指采购要做好供应商资历评估,并配合质检做好原料品质控制工作.保量,主要是指在保证企业生产.运营的同时,不多买也不少买.适时,主要是指采购要跟踪