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

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的更多相关文章

  1. Session for SSRS Report of Microsoft Dynamics AX

    Session for SSRS Report of Microsoft Dynamics AX 版权声明:本文为博主原创文章,未经博主允许不得转载. Contract •A data contrac ...

  2. Microsoft Dynamics AX 7 新特性探索 - Demo 部署(Part 1)

    Dynamics AX 7已经发布了一段时间了,我们知道这次微软为我们带来了许多令人激动的新特性.在这个系列里,Reinhard将揭开New Dynamics AX的神秘面纱,和大家一起探索这些新的特 ...

  3. Dynamics AX 2012 的工业物联网解决方案

    Dynamics AX 2012 的工业物联网解决方案 物联网 物联网的概念在这两年非常火,包括近期很火的共享单车初创公司--摩拜单车,在产品中运用了Azure Iot物联网技术.但是,物联网并不是一 ...

  4. Dynamics AX 2012 在BI分析中建立数据仓库的必要性

    AX系统已有的BI分析架构 对于AX 的BI分析架构,相信大家都了解,可以看Reinhard之前的译文[译]Dynamics AX 2012 R2 BI系列-分析的架构 . AX 的BI分析架构的优势 ...

  5. Dynamics AX 2012 R2 业务系列-销售业务流程

    在博文Dynamics AX R2 业务系列中,Reinhard对这个系列做了一个规划,下面我们就按照规划开始说业务吧. 1.销售的主要职责 其实这里说的职责主要是针对销售文员,并非整天外面满世界跑业 ...

  6. Dynamics AX 2012 R2 安装Reporting Services 扩展

    今天Reinhard在VS中部署SSRS报表时,接到以下错误: 部署因错误而被取消.在报表服务器上,验证:-SQL Server Reporting Services 服务是否正在运行. 接着,Rei ...

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

    在博文Dynamics AX R2 业务系列中,Reinhard对这个系列做了一个规划,下面我们就按照规划开始说业务吧. 国际惯例,从采购开始. 1.采购的主要职责 简单点说,采购的主要职责,是从供应 ...

  8. Dynamics AX 2012 R2 业务系列

    在之前的一系列博文里,Reinhard介绍了Dynamics AX Demo的安装与配置.相信同学们看完后,都已经成功拥有了一个测试环境. 众所周知的是,ERP作为一个特殊的软件系统,他有着背后的业务 ...

  9. Dynamics AX 2012 R2 如何处理运行时间较长的报表

    当处理的数据量较多,逻辑比较复杂时,报表可能会超时.为了解决这个问题,Reinhard一直使用SrsReportDataProviderPreProcess来做预处理报表.它会在调用SSRS前,在AX ...

随机推荐

  1. C语言深度剖析学习错误点记录

    0. static修饰变量和函数 static修饰变量,1)限定作用域,本文件内.全局变量(自定义起,本文件前面要用需extern声明),局部变量函数内:2)生命周期,程序运行期间一直保存. stat ...

  2. PLSQL 的简单命令之三

    -- 查找两个表中ID相等的 select a.id, a.name,b.math from stu a,scores b where a.id = b.id -- 右外连接 select b.id, ...

  3. 浅谈C#抽象方法、虚方法、接口

    每次写博客,第一句话都是这样的:程序员很苦逼,除了会写程序,还得会写博客!当然,希望将来的一天,某位老板看到此博客,给你的程序员职工加点薪资吧!因为程序员的世界除了苦逼就是沉默.我眼中的程序员大多都不 ...

  4. 使用工具追踪Entity Framework生成的SQL

    学习entity framework期间收集的文章,转自http://www.cnblogs.com/hiteddy/archive/2011/10/01/Difference_among_IQuer ...

  5. .NET业务实体类验证组件Fluent Validation

    认识Fluent Vaidation. 看到NopCommerce项目中用到这个组建是如此的简单,将数据验证从业务实体类中分离出来,真是一个天才的想法,后来才知道这个东西是一个开源的轻量级验证组建. ...

  6. Sql清理日志文件

    场景: 我们导入MR数据时发现磁盘空间不够用了,导致的结果就是我们的程序很可能会抛出异常了,我们需要导入数据的时候进行日志瘦身. 问1:导入数据的时候,瘦身是否会造成数据库的异常? DBA提供解决方案 ...

  7. 通用窗口类 Inventory Pro 2.1.2 Demo1(中)

    本篇想总结的是Inventory Pro中通用窗口的具体实现,但还是要强调下该插件的重点还是装备系统而不是通用窗口系统,所以这里提到的通用窗口类其实是通用装备窗口类(其实该插件中也有非装备窗口比如No ...

  8. ads

    (3) Make可以编译整个工程,并生成映像文件.在ADS中,ARM提供了三种映像文件,      1. Debug:      使用本生成目标生成的映像文件中包含了所有的调试信息,用于开发过程中使用 ...

  9. JQuery下CheckBox全选全不选反选

    <script src="JS/jquery-1.7.1.js"></script> <script type="text/javascri ...

  10. Java基础(41):Java中集合中需要注意的几个要点(关于Collection与Map)

    同步性     Vector是同步的.这个类中的一些方法保证了Vector中的对象是线程安全的.而ArrayList则是异步的,因此ArrayList中的对象并 不是线程安全的.因为同步的要求会影响执 ...