简体   繁体   English

如何解决“无法找到类型或命名空间”编译错误?

[英]How do I resolve “Type or namespace could not be found” compilation error?

I'm concerned that the web hosting that I'm paying for is not configured correctly. 我担心我付的网络托管配置不正确。 ASP.NET Web Sites which compile and run correctly on my local machine don't work once they're deployed. 在我的本地计算机上正确编译和运行的ASP.NET网站在部署后无法运行。

The issue I'm dealing with is a compilation error: CS0246, "Type or namespace could not be found (Are you missing a 'using' directive or assembly reference?) 我正在处理的问题是编译错误:CS0246,“无法找到类型或命名空间(您是否缺少'using'指令或程序集引用?)

My Web Site contains the following files and folders: 我的网站包含以下文件和文件夹:

websitedemo/Default.aspx
websitedemo/Default.aspx.cs
websitedemo/App_Code/HelloClass.cs

The compilation error occurs if I attempt to use any code contained in my App Code folder. 如果我尝试使用我的应用程序代码文件夹中包含的任何代码,则会发生编译错误。 I've included the entire /websitedemo/ folder in this archive if it helps troubleshoot the error: http://kivin.ca/websitedemo/source.zip 我已将整个/ websitedemo /文件夹包含在此存档中,如果它有助于解决错误: http//kivin.ca/websitedemo/source.zip

I've left the folder in debug mode. 我已将文件夹保留在调试模式下。 The compilation error screen may be viewed at http://kivin.ca/websitedemo/ 可以在http://kivin.ca/websitedemo/上查看编译错误屏幕

Best regards. 最好的祝福。

-- update: - 更新:

If it helps troubleshoot this error, I've got the behaviour that occurs when I attempt to deploy an ASP.NET WebApplication instead of Website. 如果它有助于解决此错误,我会遇到当我尝试部署ASP.NET WebApplication而不是网站时发生的行为。

In the case that my aspx file includes a @Page direct like this: 在我的aspx文件包含这样的@Page直接的情况下:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="myproj._Default" Debug="true" %>

The compilation error I get is: 'Parser Error Message: Could not load type 'myproj._Default'.' 我得到的编译错误是:'解析器错误消息:无法加载类型'myproj._Default'。'

The webapps are being deployed via ftp using Build -> Publish -> [X] Replace matching files, [X] Only files needed to run this app. 使用Build - > Publish - > [X]替换匹配文件,[X]仅运行此应用程序所需的文件,通过ftp部署webapps。 [X] Include App_Data folder. [X]包含App_Data文件夹。

I'd like to thank everyone for their support. 我要感谢大家的支持。 It's most appreciated. 非常感谢。 I've been in contact with a specialist at my web hosting company and they've advised me that this isn't a code or server configuration error, but just a missed step in my control panel. 我一直与我的网络托管公司的专家联系,他们告诉我这不是代码或服务器配置错误,而只是我的控制面板中错过了一步。 Setting my website working directory as a virtual dir resolved the issue. 将我的网站工作目录设置为虚拟目录解决了该问题。

Thanks to the stack overflow community and the outstanding support people at Softsys Hosting. 感谢堆栈溢出社区和Softsys Hosting的出色支持人员。

如果你在本地构建你的站点并将生成的dll(包含HelloClass)上传到bin目录,我敢打赌它会起作用。

尝试将HelloClass.cs放在命名空间中,并将Using放在默认文件的顶部

http://msdn.microsoft.com/en-us/library/54dwfbb7.aspx http://msdn.microsoft.com/en-us/library/54dwfbb7.aspx

i think this may help you... if you have subfolders 我认为这可能对你有帮助......如果你有子文件夹

also, app_code was introduced in framework 2.0, can you check that the web application on the live box is set to use framework 2.0 ? 另外,app_code是在框架2.0中引入的,你可以检查活动框上的Web应用程序是否设置为使用框架2.0? otherwise the classes wont get compiled in there 否则这些类不会在那里编译

暂无
暂无

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

相关问题 编译错误:找不到类型或名称空间名称 - Compilation Error: The type or namespace name could not be found 编译错误找不到类型或名称空间名称 - Compilation Error The type or namespace name could not be found 如何使用 UWP 6.2.10 解决“找不到类型或命名空间‘系统’”? - How do I resolve “The type or namespace 'System' could not be found” with UWP 6.2.10? 如何修复“无法找到类型或命名空间名称”? - How do I fix “The type or namespace name could not be found”? 如何解决 VS Code 中的“找不到类型或命名空间名称‘系统’”错误? - How can I resolve "The type or namespace name 'System' could not be found" errors in VS Code? 我的代码中出现错误“找不到类型或名称空间名称&#39;spsite&#39;”,我不知道如何解决它 - I have an error in my code “the type or namespace name 'spsite' could not be found” that I have no idea how to solve it 如何统一修复“找不到类型或命名空间名称”错误? - How to fix 'The type or namespace name could not be found ' error in unity? 如何解决 AssetBundle 上的“找不到类型或命名空间名称”错误 - How to solve the error “type or namespace name could not be found” on AssetBundle 错误:找不到类型或名称空间AdvancedTextBoundary - Error: The type or namespace AdvancedTextBoundary could not be found 找不到错误类型或名称空间名称配置文件常见 - error type or namespace name profilecommon could not be found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM