Using .NET Generics to store ArcObjects?

The warning you received is because you have your class (or assembly) marked with:

[ComVisible(true)]

This causes the compiler to issue warnings when you use types that are not compatible with COM objects.

That being said, there is no problem with using generics with ArcObject types. You should, however, only use them for types that are internal to your application - ie: when you're working with a set of values.


I don't have an issue getting it to compile.

I am using C# 3.5

using System; 
using System.Collections.Generic; 
using System.Web;
using ESRI.ArcGIS.Carto;  //Perhaps not having this reference is the issue?

public class Foo
    {
        private List<ILayer> _fooLayers;

        public List<ILayer> FooLayers
        {
            get { return _fooLayers; }
            set { _fooLayers = value; }
        }
    }