Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having some problems using IfieldChecker.

I have this following code, which I'm trying to test permitted/not permitted fields, according to my workspace

public IEnumerable<IFieldError> GetFieldErrors()

        IFieldChecker checker = new FieldCheckerClass();
        IEnumFieldError fieldErrors = null;

        checker.ValidateWorkspace = this.WorkspaceHandler.GetCurrentWorkspace;
        checker.Validate(this.Fields,out fieldErrors,out this._ValidatedFields);

        if (fieldErrors == null)
            yield return null;
            IFieldError fError = fieldErrors.Next();

            while (fError != null)
                // debug only  

                yield return fError;
                fError = fieldErrors.Next();

        yield break;

Heres the test

    public void FieldBuilder_TestGetFieldErrors()
        fBuilder = new FieldBuilder(this.wHandler);

        fBuilder.AddField(name, alias, esriFieldType.esriFieldTypeBlob, length, doublePrecision, doubleScale, false, false, null,
            false, null);

        Assert.AreEqual(2, fBuilder.GetFieldErrors().Count());

In my opinion, this should yield 1. The test completes, and it gives me a green light, but it should fail, since I'm testing with a bunch of values (1, 2, etc.);

The workspace I'm creating is one on C:\, therefore, should not allow a Blob field type.

Any ideas why this is working like this?

EDIT: I'm working under the premise that after setting the workspace, ArcObjects would take care of validating it and telling me which types of fields are permitted or not.

Example: FileSystemWorkspace - cannot have Blob field types;

Or, does IFieldChecker does not work the way I'm thinking?

share|improve this question
What's the output from the Console.WriteLine() calls? – Javier Mollá Jul 27 '10 at 9:50
I don't think we should be using tags for specific interfaces... that would get messy real quick. – JasonBirch Aug 13 '10 at 22:55
no problem jason :P – George Aug 14 '10 at 22:07
Shouldn't those last couple of parameters to Validate be ref, not out? I'd have to gin up a test here to be sure, but this sort of thing has nailed me before. IFieldChecker.Validate documentation – Herb Sep 1 '10 at 12:07
No, the type library importer turns it into "out". Anyway, in C#, you cannot freely interchange out and ref modifiers, using ref when the signature defines a parameter as out wouldn't even compile. – Petr Krebs Sep 1 '10 at 12:49
up vote 2 down vote accepted

Short version is that the types are (apparently) not checked. I can get Validate to fail for a shapefile if I give it a long field name, or names with invalid characters, but not by giving a bad data type. The documentation does imply that it's only checking names as it states:

"The error codes are stored as a esriFieldNameErrorType." See esriFieldNameErrorType.

What's interesting is that when I feed it a esriFieldTypeBlob and call Validate, the field type gets changed to esriFieldTypeInteger, even though no error is thrown.

It's kind of implied by the other [out] parameter - "fixedFields". It's thoughtfully fixed your incorrect field definitions for you.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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