asp.NET 2.0网站无法在APP_ code类访问 [英] asp.NET 2.0 Web Site Can't Access Classes in App_Code
问题描述
我有部署我的网站到服务器后,访问类的问题。
请注意,这是一个基于Web的网站的非Web的应用程序的.The错误是:
I'm having a problem accessing a class after deploying my website to a server. Note that this is a Web Site not Web Application.The error is:
编译器错误信息:CS0246:类型或命名空间名称订单找不到(是否缺少using指令或程序集引用?)
版本信息:Microsoft .NET Framework版本:2.0.50727.1433; ASP.NET版本:2.0.50727.1433
我已经做了很多谷歌搜索,并一直没能找到任何帮助。
I've done a lot of googling and haven't been able to find anything that helps.
我的code看起来像这样(我得到声明令行编译器错误):
My code looks like this (I get the compiler error on the line declaring Order):
//Default.aspx.cs
namespace Foo
{
public partial class _Default : System.Web.UI.Page
{
private Order custOrder;
....etc
}
}
在APP_ code文件夹我有Order.cs:
In the App_Code folder I have Order.cs:
namespace Foo
{
public class Order
{
....etc
}
}
但奇怪的是,这工作正常,并在当地的开发环境。当我将其移动到QA环境,当我得到这个错误的。
The strange thing is that this works fine locally and in a dev environment. When I move it to a qa environment, that's when I get that error.
我部署通过提交所有code Subversion库,然后做在服务器计算机导出。
I deploy by committing all the code to a subversion repository and then doing an export on the server machines.
我想这可能是某种命名空间的错误,但我不知道为什么它会在某些机器上工作,而不是别人。
I guess it could be some kind of namespace error, but I don't know why it would work on some machines and not others.
任何想法可能是,可能会导致这样一个不同的服务器上的不同?所有机器报告.NET版本2.0
Any idea what could be different on a different server that might cause this? All machines report the .net version as 2.0
推荐答案
,因为它说,错误意味着它无法找到该类型。
As it says, the error means that it couldn't find that type.
可能的原因:
-
一个编译错误$ P $的编译pvented在APP_ code文件夹中的文件的.cs。当ASP.NET着眼于编译code,它不能找到你要找的,这样错误的类。
A compilation error prevented the .cs files in your app_code folder from being compiled. When ASP.NET looks at the compiled code, it can't find the class you're looking for, thus the error.
在的.cs文件未部署到APP_ code。显然,如果源文件不在现场,他们无法进行编译。
The .cs files weren't deployed to app_code. Obviously if the source files aren't in the site, they can't be compiled.
一个权限问题是$ P $从加载的.cs文件pventing服务器。
A permissions issue is preventing the server from loading the .cs files.
你的一个网页被错误地引用类 - 也许在.cs或在.aspx一个错字,一类移动到一个新的命名空间或重命名等。
One of your pages is incorrectly referencing the class - perhaps a typo in the .cs or the .aspx, a class moved to a new namespace or renamed, etc.
基本上,源无法找到,存取或编译。
Essentially, the source couldn't be found, accessed or compiled.
这篇关于asp.NET 2.0网站无法在APP_ code类访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!