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();

Are you initializing ?

This works for me:

class Program
    private static LicenseInitializer m_AOLicenseInitializer = new DesktopConsoleApplication1.LicenseInitializer();
    static void Main(string[] args)
        //ESRI License Initializer generated code.
            new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeArcInfo },
            new esriLicenseExtensionCode[] { });

            IFeatureClassName fcn = new FeatureClassNameClass();
            ((IDatasetName)fcn).Name = "test";
        catch (Exception ex)
        Console.WriteLine("press enter to close window");

        //ESRI License Initializer generated code.
        //Do not make any call to ArcObjects after ShutDownApplication()

This LicenseInitializer code was created by the VS2010 project template for New arcgis console app:

internal partial class LicenseInitializer
    public LicenseInitializer()
        ResolveBindingEvent += new EventHandler(BindingArcGISRuntime);

    void BindingArcGISRuntime(object sender, EventArgs e)
        // TODO: Modify ArcGIS runtime binding code as needed
        if (!RuntimeManager.Bind(ProductCode.Desktop))
            // Failed to bind, announce and force exit
            Console.WriteLine("Invalid ArcGIS runtime binding. Application will shut down.");
  • Hi Kirk- above my Main I have private static IAoInitialize m_pAoInitialize; And in my Main I have IAoInitialize ao = new AoInitialize(); ao.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcInfo); Is there any issue with the way I have setup my licenseInitializer? – Josh Feb 3 '11 at 20:58
  • I'm able to go through other functions that use ArcObjects and I don't get an error there. But if I have not initialized my licenseinitialzer the best way then I need to – Josh Feb 3 '11 at 21:00
  • If you are on arc10.0, you'll need to use the runtime binding. help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/… – Kirk Kuykendall Feb 3 '11 at 21:43
  • Hi Kirk- I had forgot to include another line of my code where I do actually do the runtime binding so I believe I am doing that correctly. Besides, there are a number of other functions that use ArcObjects that I have no trouble on. Neil Clemmons on ESRI forums responded with an interesting response in the below link. I still don't understand why FeatureClassName has no constructor based on what he said but I will try to do what he suggests. Your thoughts? forums.arcgis.com/threads/… – Josh Feb 7 '11 at 14:07
  • What happens if you create a new project (new arcgis console app) with references to necessary assemblies, then copy and paste the code I posted? – Kirk Kuykendall Feb 7 '11 at 16:13

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

  • Same here. This solved it perfectly for me. Don't know why this isn't the accepted answer – Loko Jan 7 '14 at 14:18
  • This was the solution for me as well. Had the issue after upgrading a project from ArcGIS 10.3 to 10.4 and changing the .net framework from 3.5 to 4.5 – Tim Sexton Jun 7 '16 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.