Carto vs. Display - IFeatureLayer

867
3
Jump to solution
03-13-2013 01:43 PM
deleted-user-VeC5jUIlNXtq
Occasional Contributor III
Hey,

Quick info: VS2010 Express, developing using vb.net against the .NET 4.0 for ArcGIS 10.1 SP1

I haven't found an exact solution to my issue, just some similar issues.

Long story short I've got the following lines of code:

        Dim pTemplateLayer As IFeatureLayer
        pTemplateLayer = New FeatureLayer

When I go to the References of my project and select "Unused References..." it brings up ESRI.ArcGIS.Display, so I decide to remove as I have been doing with all other projects.

It brings up an error saying "Implementing class 'ESRI.ArcGIS.Carto.FeatureLayerClass' for interface 'ESRI.ArcGIS.Carto.FeatureLayer' cannot be found."

I re-add the Display reference and all is well. Interestingly, if I remove the reference to Display and change the " = New FeatureLayer" to " = New FeatureLayerClass" I'm asked to reference Display.

Could somebody give me a quick explanation of this behavior? Why is Display being thought of as an Unused Reference by Visual Studio, but required at the same time?

Thanks!
0 Kudos
1 Solution

Accepted Solutions
AlexanderGray
Occasional Contributor III
This is a little tricky but I will try. 
Basically some classes belong to some assemblies but have dependencies on objects in other assemblies.  Some of the interfaces implemented by FeatureLayer are in the Display assembly.  Some of the methods (such as draw) need objects in the Display assembly.

As far as the difference between "FeatureLayer" and "FeatureLayerClass" it has to do with the way the COM Interop is build.  Each represent a different RCW (run time callable wrapper) to the same COM class.    Using "FeatureLayer" amounts to using the "class interface" which I believe is the default IFeatureLayer (which is in the Carto assembly.)  Using "FeatureLayerClass" is the second RCW which points to the FeatureLayer COM class (which would let the compiler know that any assembly dependency would need to be included.)  Esri states that you should always use the FeatureLayerClass type of instantiation because the default interface of a class could change (making the use of FeatureLayer unpredictable.)


http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Using_ArcObjects_COM_ba...

View solution in original post

0 Kudos
3 Replies
AlexanderGray
Occasional Contributor III
This is a little tricky but I will try. 
Basically some classes belong to some assemblies but have dependencies on objects in other assemblies.  Some of the interfaces implemented by FeatureLayer are in the Display assembly.  Some of the methods (such as draw) need objects in the Display assembly.

As far as the difference between "FeatureLayer" and "FeatureLayerClass" it has to do with the way the COM Interop is build.  Each represent a different RCW (run time callable wrapper) to the same COM class.    Using "FeatureLayer" amounts to using the "class interface" which I believe is the default IFeatureLayer (which is in the Carto assembly.)  Using "FeatureLayerClass" is the second RCW which points to the FeatureLayer COM class (which would let the compiler know that any assembly dependency would need to be included.)  Esri states that you should always use the FeatureLayerClass type of instantiation because the default interface of a class could change (making the use of FeatureLayer unpredictable.)


http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Using_ArcObjects_COM_ba...
0 Kudos
LeoDonahue
Occasional Contributor III
Good information Alexander,

I was going to say that I experience the same thing in Eclipse. 

If I import a package, and declare and instantiate a variable from that package, but never use it again, Eclipse will complain to me that the variable is unused.  I thought perhaps the OP was experiencing something like this with VS, but was not sure.
0 Kudos
deleted-user-VeC5jUIlNXtq
Occasional Contributor III
Thanks for the replies.

I'm definitely beginner in terms of developing, so a lot of the links between libraries are foregin to me. I'm essentially self-taught, with some basic University background in C++.

I'll definitely have to read what agray1 linked as I'm sure there is some good information in there.

Still a little confusing, but at least that's a start 😛

Interestingly, we have another program that does almost exactly the same thing as this one (without going into details as to why we have 2), and it doesn't experience this issue. The functionality is almost identical (turn .dxf points into a feature class of a geodatabase), however one is for a very large project, the other is for our standard smaller project setups. Much of the code is identical.

I'll have to do some digging, but at least I've got a start.
0 Kudos