Search code examples
c#datamember

DataMember property cannot be found on the DataSource in autogenerated code


I know this has been asked before, but I've looked around and I can't find anything that quite matches what my problem is, so apologies for the dupe post.

I am writing a .NET #.5 app in C# that uses an internal SqlCE DB. Whenever I run the app in the debugger, I get the error listed in the title on the BindingSource line below:

this.Load += new System.EventHandler(this.Main_Load);
((System.ComponentModel.ISupportInitialize)(this.dbCDRDataSet1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.animalControlBindingSource)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();

This is in the Designer.cs portion of my main form (Main.Designer.cs). If I comment out the code, it all seems to work perfectly, but since it's autogen code, it pops back up every time.

Some background on the DB structure:

My database is dbCDR.sdf. I have one dataset, dbCDEDataSet1.xsd, which contains all tables. One of the tables is called AnimalControl.

If I try to rewrite the offending line, Intellisense gives me the same result the autogen code does.

I have tried deleting and recreating the dataset (with the same name) a few times, just to see if it will force a more complete refresh.

I can give any more details as needed, just let me know. Thanks so much!


Solution

  • In animalControlBindingSource you need to set the name of the source as "AnimalControl" if it is its proper name not the name with the space you used.

    Should be in designer file somewhere.