I've come across an issue with MXD relates and I need a .NET solution to add them to a map. I started with a sample that uses ArcObjects, but I hit a stumbling block with the IMapTableInfo Interface. I have no idea how to get or set this object. I've read the documentation page, but it doesn't seem to have any useful information (that I understood).
Has anyone used this object?
Does anyone have code samples using IMapTableInfo that can help me?
Does anyone have code samples that can help me add MXD relates?
This is the code sample I've already found (the problem being that it expects a valid IMapTableInfo object as a parameter):
IRelateInfos pRIs = null;
IRelateInfo pRI = null;
pRIs = pMTI.RelateInfos;
if (pRIs == null)
Console.WriteLine(“No relationship is available”);
for (int j = 0; j < pRIs.Count; j++)
pRI = pRIs.get_Element(j);
Console.WriteLine(pRI.Name + “, " + pRI.RelationshipID + “, ” + pRI.RelatedTableID + “\n”);
I've also explored Python and geoprocessing as options. There is no method to "Add Relates" in ArcMap. It does exist in ArcGIS Pro, but that product is basically nonfunctional.
Solved! Go to Solution.
Just had a look at the API. Looking at this page it seems to be related to Mapserver, are you trying to use this in an addin for say desktop? If so I don't think it will work. It was not clear if you are developing a desktop solution or some sort of server application?
I got it working with Yuan Liu's suggestion. Thank you very much. I had not previously found that sample. Just be wary that some of the syntax is wrong in some in the VB.NET sample. You have to piece it together from the C# and VBA samples. Then read the documentation on IMemoryRelationshipClassFactory as well. That helped me to discover I had switched my field names for the Primary and Foreign keys when I was receiving a generic COM Error.
To clarify, this was to develop a .NET addin for ArcMap 10.3 (Desktop).