+ Reply to Thread
Results 1 to 8 of 8

Thread: What is the best syntax here??

  1. #1
    Joshua Vickrey
    Join Date
    Apr 2010
    Posts
    239
    Points
    0
    Answers Provided
    0


    0

    Default What is the best syntax here??

    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??

    Code:
    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 debugging

    Code:
    IFeatureClassName pOutFeatClassName = (IFeatureClassName)new FeatureClassName();
    Does anyone have any suggestions for me? Thanks

  2. #2
    Neil Clemmons

    Join Date
    Apr 2010
    Posts
    894
    Points
    570
    Answers Provided
    94


    0

    Default Re: What is the best syntax here??

    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.
    Neil Clemmons
    Geographic Information Services, Inc.
    http://www.gisinc.com

    Check out our blog:
    http://blog.gisinc.com

  3. #3
    Venkata Rao Tammineni

    Join Date
    Aug 2010
    Posts
    443
    Points
    0
    Answers Provided
    0


    0

    Default Re: What is the best syntax here??

    Quote Originally Posted by jvickrey79 View Post
    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??

    Code:
    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 debugging

    Code:
    IFeatureClassName pOutFeatClassName = (IFeatureClassName)new FeatureClassName();
    Does anyone have any suggestions for me? Thanks
    Use something like below

    IFeatureClassName pOutFeatClassName = new FeatureClassNameClass();
    Thanks and Regards,

    Venkat Tammineni

    venkat@muravema.com

  4. #4
    Joshua Vickrey
    Join Date
    Apr 2010
    Posts
    239
    Points
    0
    Answers Provided
    0


    0

    Default Re: What is the best syntax here??

    Quote Originally Posted by vtammineni View Post
    Use something like below

    IFeatureClassName pOutFeatClassName = new FeatureClassNameClass();
    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.

  5. #5
    Joshua Vickrey
    Join Date
    Apr 2010
    Posts
    239
    Points
    0
    Answers Provided
    0


    0

    Default Re: What is the best syntax here??

    Quote Originally Posted by Neil View Post
    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.
    Neil do you know how I can fix this issue on the FeatureClassNameClass object without using IDataset.FullName? I'm not sure what has caused this. Could a custom class be created that could get this working on FeatureClassNameClass?

  6. #6
    Neil Clemmons

    Join Date
    Apr 2010
    Posts
    894
    Points
    570
    Answers Provided
    94


    0

    Default Re: What is the best syntax here??

    While there are classes in the ArcObjects model that you can't create yourself, it appears that the FeatureClassName class isn't one of them. Your code should be fine. Make sure you have all of the appropriate library references added to your project. As far as I know, ESRI.ArcGIS.Geodatabase and ESRI.ArcGIS.System are required but there may be others (check the dev help).
    Neil Clemmons
    Geographic Information Services, Inc.
    http://www.gisinc.com

    Check out our blog:
    http://blog.gisinc.com

  7. #7
    Venkata Rao Tammineni

    Join Date
    Aug 2010
    Posts
    443
    Points
    0
    Answers Provided
    0


    0

    Arrow Re: What is the best syntax here??

    Quote Originally Posted by jvickrey79 View Post
    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.
    Hi,

    IFeatureClass is an interface..

    http://help.arcgis.com/en/sdk/10.0/a...00002s3000000/

    FeatureClassName is coclass..its a creatable class..

    http://help.arcgis.com/en/sdk/10.0/a...00000ms000000/

    Something like this...

    IFeatureClass inFeatureClass = (IFeatureClass)lName.Open();
    IFeatureClassName inFeatureClassName = (IFeatureClassName)lName;
    IFeatureClassName outFeatureClassName = new FeatureClassNameClass();
    IDatasetName outDatasetName = (IDatasetName)outFeatureClassName;
    IDataset outWorkspaceDataset = (IDataset)outWorkspace;
    IWorkspaceName outWorkspaceName = (IWorkspaceName)outWorkspaceDataset.FullName;
    outDatasetName.WorkspaceName = outWorkspaceName;
    Thanks and Regards,

    Venkat Tammineni

    venkat@muravema.com

  8. #8
    gur hanan
    Join Date
    Apr 2010
    Posts
    1
    Points
    0
    Answers Provided
    0


    0

    Default Re: What is the best syntax here??

    Hi,
    I had the same problem and I fixed it by changing the project "target framework" from 4.0 to 3.5 (in the application tab on the project properties).
    Esri dose not support .Net framework 4.0 yet.
    Gur

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts