简体   繁体   English

VS2005,C# - 数据绑定组合框 - 默认情况下代码隐藏给我错误

[英]VS2005, C# - Databound combo boxes - code behind is giving me errors by default

In the designer.cs portion of the code, I simply made the combo boxes database driven (it previewed the data fine, so that works) but when I try to compile, it throws me a 2 unique errors: 在代码的designer.cs部分,我只是简单地对组合框进行数据库驱动(它预览数据很好,这样才有效)但是当我尝试编译时,它会抛出2个独特的错误:

1) Error 1 The type name 'mtdDesktopApplicationDataSet' does not exist in the type 'DesktopApplication.DesktopApplication' 1)错误1类型名称'mtdDesktopApplicationDataSet'在“DesktopApplication.DesktopApplication”类型中不存在

2) Error 2 The type name 'mtdDesktopApplicationDataSetTableAdapters' does not exist in the type 'DesktopApplication.DesktopApplication' 2)错误2类型名称'mtdDesktopApplicationDataSetTableAdapters'在“DesktopApplication.DesktopApplication”类型中不存在

The first error is on the first line, the other error shows up wherever 'mtdDesktopApplicationDataSetTableAdapters' is (4 lines) 第一个错误在第一行,另一个错误显示在'mtdDesktopApplicationDataSetTableAdapters'的任何地方(4行)

All the appropriate files appear to be there, but they just aren't hooking up right? 所有相应的文件似乎都在那里,但它们只是没有连接好吗?

this.mtdDesktopApplicationDataSet = new DesktopApplication.mtdDesktopApplicationDataSet();
this.tblStudyBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.tblStudyTableAdapter = new DesktopApplication.mtdDesktopApplicationDataSetTableAdapters.tblStudyTableAdapter();
this.tblDeliveryGroupBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.tblDeliveryGroupTableAdapter = new DesktopApplication.mtdDesktopApplicationDataSetTableAdapters.tblDeliveryGroupTableAdapter();
this.tblDeliveryBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.tblDeliveryTableAdapter = new DesktopApplication.mtdDesktopApplicationDataSetTableAdapters.tblDeliveryTableAdapter();
this.tblDeliveryDataSetBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.tblDeliveryDataSetTableAdapter = new DesktopApplication.mtdDesktopApplicationDataSetTableAdapters.tblDeliveryDataSetTableAdapter();
 ((System.ComponentModel.ISupportInitialize)(this.mtdDesktopApplicationDataSet)).BeginInit();
 ((System.ComponentModel.ISupportInitialize)(this.tblStudyBindingSource)).BeginInit();
 ((System.ComponentModel.ISupportInitialize)(this.tblDeliveryGroupBindingSource)).BeginInit();
 ((System.ComponentModel.ISupportInitialize)(this.tblDeliveryBindingSource)).BeginInit();
 ((System.ComponentModel.ISupportInitialize)(this.tblDeliveryDataSetBindingSource)).BeginInit();

Have you moved/renamed the files/classes at any point, and/or changed the project's default namespace? 您是否在任何时候移动/重命名了文件/类,和/或更改了项目的默认命名空间? I've seen all of these have similar effects to the above. 我已经看到所有这些都具有与上述相似的效果。

Re the (generated) line: 重新生成(生成)行:

this.mtdDesktopApplicationDataSet =
        new DesktopApplication.mtdDesktopApplicationDataSet();

It is probably worth avoiding having fields ( this.mtdDesktopApplicationDataSet ) named the same as types ( DesktopApplication.mtdDesktopApplicationDataSet ) - that can only lead to potential for bugs. 可能值得避免将字段( this.mtdDesktopApplicationDataSet )命名为与类型( DesktopApplication.mtdDesktopApplicationDataSet )相同 - 这只会导致潜在的错误。 It isn't clear (without being able to reproduce it) whether that is a factor here, but it can't help any... 目前尚不清楚(无法重现)这是否是一个因素,但它不能帮助任何...

What is the field mtdDesktopApplicationDataSet meant to represent? mtdDesktopApplicationDataSet表示的字段是什么? Can you rename it? 你可以重命名吗?

I'm guessing you're experiencing some issues with namespaces. 我猜你正在遇到名称空间的一些问题。 If this code-behind file resides in the DesktopApplication namespace and you also have a DesktopApplication class in the DesktopApplication namespace, you will experience the above. 如果这个代码隐藏文件驻留在DesktopApplication命名空间,你也有一个DesktopApplication在类DesktopApplication命名空间,你会体验到以上。

(Basically it's looking at DesktopApplication.DesktopApplication when it should be looking at DesktopApplication instead.) (基本上它在查看DesktopApplication.DesktopApplication时应该关注DesktopApplication 。)

Try cleaning up your namespaces so the above is not true, or escape the namespace hell with the global keyword: 尝试清理你的命名空间,所以上面不是这样,或者使用global关键字转义命名空间地狱:

this.mtdDesktopApplicationDataSet = new global::DesktopApplication.mtdDesktopApplicationDataSet();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM