简体   繁体   English

类型未定义VB.NET

[英]Type is not defined VB.NET

I have a VB.NET project where I create a class that inherits a ComboBox: 我有一个VB.NET项目,在其中创建了一个继承ComboBox的类:

Public Class myComboBox
    Inherits System.Windows.Forms.ComboBox
End Class

In the project where I am using this, if I add this control, myComboBox onto a form, I get the following error: 在我正在使用它的项目中,如果我将此控件myComboBox添加到窗体上,则会出现以下错误:

Error 1 Type 'myProject.myComboBox' is not defined. 错误1类型'myProject.myComboBox'未定义。

If I do the exact same thing in a brand new project, everything works just fine. 如果我在一个全新的项目中做同样的事情,那么一切都会很好。 The project has no errors and will execute. 该项目没有错误,将执行。

Any ideas? 有任何想法吗?

Your first try would be Clean the solution,and Rebuild it. 您的第一个尝试是“ Clean解决方案,然后Rebuild

Visual Studio > Build > Clean Solution and then Re-Build Solution Visual Studio > Build > Clean Solution ,然后Re-Build Solution

Your best bet is to check both your custom-control and project's targeted Dot.Net framework is the same.If they are different,then this is an obvious error 最好的选择是检查自定义控件和项目的目标Dot.Net框架是否相同。如果它们不同,那么这显然是错误的

But as you mentioned , it works in a new project right ? 但是,正如您提到的,它可以在新项目中起作用吗? So , create a new project,add all the .vb files from your previous project,double click to load the designer(there might be one or two errors but they are easily fixable).Then you have a completely new project,Now add the .dll of the usercontrol/Custom Control you created. 因此,创建一个新项目,添加上一个项目中的所有.vb文件,双击以加载设计器(可能有一个或两个错误,但它们很容易修复)。然后您有了一个全新的项目,现在添加您创建的usercontrol / Custom Control的.dll。

Hope this helps :) 希望这可以帮助 :)

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

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