IFeatureClassName pOutFeatClassName = (IFeatureClassName)new FeatureClassNameClass();
IFeatureClassName pOutFeatClassName = (IFeatureClassName)new FeatureClassName();
In my C# console application I tried using the below line of code to declare a IFeatureClassName object but Visual Studio 2010 says that FeatureClassNameClass() has No Constructors defined. What??IFeatureClassName pOutFeatClassName = (IFeatureClassName)new FeatureClassNameClass();
Also If I changed my code to the below line of code Visual Studio will not show any errors on the syntax but when I start debugging my application and I reach this line, Visual Studio throws a crazy error stating something like "error on vshost32.. and just stops debuggingIFeatureClassName pOutFeatClassName = (IFeatureClassName)new FeatureClassName();
Does anyone have any suggestions for me? Thanks
Use something like below
IFeatureClassName pOutFeatClassName = new FeatureClassNameClass();
The error means that the FeatureClassName class does not have a public constructor, meaning that you cannot create a new instance of the class. You obtain a reference to this type of object from another class which is capable of accessing the private constructor and returning an instance of the class to you. In your particular case, one way to get the reference you're looking for is through IDataset.FullName.
I've tried that and I get two errors. FeatureClassNameClass has no constructors defined and Interop type FeatureClassNameClass cannot be embedded so use the applicable interface instead. Neil's suggestion makes sense although I still don't understand why FeatureClassName has no constructors defined. I'll try to see if I can use Dataset.FullName instead.