vb.net 项目构建中的“类型未定义”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18255335/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"Type is not defined" error on project build
提问by sreimer
I created a new VB.net windows applications project and added a reference to my utilities project like I have done many times before. When I start coding, the editor will find the utility namespace without difficulty but when I build I get "Type My.Utils.Data is not defined".
我创建了一个新的 VB.net windows 应用程序项目,并像我以前做过很多次一样添加了对我的实用程序项目的引用。当我开始编码时,编辑器会毫不费力地找到实用程序命名空间,但是当我构建时,我得到“未定义 Type My.Utils.Data”。
I've compared my project to my other projects and can't find a difference.
我已经将我的项目与其他项目进行了比较,但找不到区别。
When I try to debug, I get a dialog saying "Visual Studio cannot start debugging because the debug target "C:.....\myproject.exe" is missing
当我尝试调试时,我收到一个对话框,提示“Visual Studio 无法开始调试,因为调试目标“C:.....\myproject.exe”丢失
回答by Steven Doggart
You need to make sure that the consuming project is targeting a .NET Framework version which is equal to or higher than the other project that it is referencing. If the referenced project is targeting a higher version of the framework, Visual Studio will not give you a useful message like, "Wrong Framework Version". Instead, it gives you a very confusing error about the assembly being missing, even though it's there.
您需要确保使用项目的目标 .NET Framework 版本等于或高于它引用的其他项目。如果引用的项目面向更高版本的框架,Visual Studio 将不会向您提供诸如“错误的框架版本”之类的有用消息。相反,它会给你一个关于缺少程序集的非常令人困惑的错误,即使它在那里。
回答by Jeff
I ran into this error and had a more unusual root cause. I'll add it here because someone may experience the same. (I don't expect this to be the "normal" cause of this error.) Anyway, I created a service reference and I removed the text "Reference" from the name of it and called it "ServiceName" rather than "ServiceNameReference. Apparently that created a naming conflict that blew up the reference.vb file.
我遇到了这个错误并且有一个更不寻常的根本原因。我会在这里添加它,因为有人可能会遇到同样的情况。(我不希望这是此错误的“正常”原因。)无论如何,我创建了一个服务引用,并从它的名称中删除了文本“Reference”并将其称为“ServiceName”而不是“ServiceNameReference”。显然,这造成了命名冲突,炸毁了 reference.vb 文件。