ArcObjects C# – No Constructor Defined Error Resolution

arcobjectsc

In my C# Console Application, Visual Studio 2010 highlights new FeatureClassNameClass() in my below line of code and states "ESRI.ArcGIS.Geodatabase.FeatureClassNameClass has No constructors defined" and then states cannot be embedded. Use aplicable interface instead. How else can I define pOutFeatClassName as type IFeatureClassName?

IFeatureClassName pOutFeatClassName = new FeatureClassNameClass();

If I change the code to below, then Visual Studio does not throw an immediate error but once I run my application Visual Studio immediately bombs at this line and only states "error vshost32.exe". What is going on? Many Thanks for any suggestions..

IFeatureClassName pOutFeatClassName = (IFeatureClassName)new FeatureClassName();

Best Answer

The solution:

  1. In your project references, find the assembly where FeatureClassNameClass is (ie ESRI.ArcGIS.Geodatabase).
  2. Right-click it and select "properties"
  3. Change "Embed interop types" to "false"

This 99% should do the trick

Related Question