编译在部署Web应用程序的错误,但不是在IDE [英] Compile errors on deployed web application, but not in the IDE

查看:206
本文介绍了编译在部署Web应用程序的错误,但不是在IDE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我部署的Web应用程序,我收到以下错误:

In my deployed web application I am getting the following error:

CS0103:名称releaseLionButton_Click'呢   在目前的情况下不存在

CS0103: The name 'releaseLionButton_Click' does not exist in the current context

它标识为违规行:

<asp:Button ID="releaseLionButton" runat="server" 
            Text="Release the Lion!"
            OnClick="releaseLionButton_Click"></asp:Button>

在code-隐藏文件,我有以下code:

In the code-behind file, I have the following code:

internal void releaseLionButton_Click(object sender, EventArgs e)
{
    if (selectedLionCage != null && selectedLionCage.DoorState == DoorState.Closed)
        selectedLionCage.OpenDoor();
}

现在我可以改变这个错误消失内部保护,这是有道理的,因为ASPX页说从$ C $定义Page类是InteritsC-隐藏文件。

Now I can make this error go away by changing internal to protected, which makes sense, since the ASPX page says it "Interits" from the Page class defined in the code-behind file.

这一切都很好。

我不明白的是,为什么与程序工作的内部当我运行在我的本地机器的IDE程序。

What I don't understand is why the program works with internal when I run the program in the IDE on my local machine.

我不希望测试运行到几百种这样愚蠢的错误,我不想做测试部署文书工作百略不同版本的程序。

I don't want the testers to run into a hundred such stupid errors, and I don't want to do the test deployment paperwork for a hundred slightly-different versions of the program.

我希望它的不起作用的IDE中,如果它不是去上班真正!

I want it to not work in the IDE if it's not going to work for real!

因此​​,这里是我的问题:

So here's my question:

我怎样才能获得本地版本的IDE生成的的编译错误全部的是,部署的版本也将经历?

How can I get the local version in the IDE to generate all of the compilation errors that the deployed version is going to experience?

更多信息分散你的注意力从真正的问题:

目标框架应用程序是.NET框架3.5。它必须是因为它引用 System.DirectoryServices.AccountManagement

The Target Framework for the application is ".NET Framework 3.5". It must be this because it references System.DirectoryServices.AccountManagement.

在测试机上的错误页面,相反,说版本信息:Microsoft .NET Framework版本:2.0.50727.4206; ASP.NET版本:2.0.50727.4209。

The error page on the test machine, in contrast, says "Version Information: Microsoft .NET Framework Version:2.0.50727.4206; ASP.NET Version:2.0.50727.4209".

然而,目录服务帐户管理code完美的作品在测试机上。我不知道发生了什么事情有两种。

And yet the Directory Services Account Management code works perfectly on the test machine. I don't know what's going on there either.

其他类似的问题,我遇到

这是一个较旧的应用程序,我维持,它会偶尔给我验证警告一些随机的ASPX文件的一个长长的清单。我解决所有这些,即使code仍然有效,因为我喜欢我的code是干净和pretty的。我还没有找到一种方法来生成目的验证警告所有文件或针对任何特定文件。

This is an older application that I am maintaining, and it will occasionally give me a long list of validation warnings for some random ASPX file. I fix all of these even though the code still works, because I like my code to be clean and pretty. I have not yet found a way to generate the validation warnings on purpose for all files or for any particular file.

有时候,我重构code(如通过改变一个变量名),它会提醒我,code目前不编译,所以重构可能无法正常工作。然而,我不知道为什么它认为code不会编译IDE来告诉我。它仍然运行完美,没有错误或警告出现在错误列表!其他时候,没有图案我已经发现,它不会重构期间显示警告消息。

Sometimes when I refactor the code (such as by changing a variable name) it will warn me that the code does not currently compile, so the refactoring may not work. And yet I cannot get the IDE to tell me why it thinks the code won't compile. It still runs perfectly, and no errors or warnings appear in the Error List! Other times, with no pattern that I have discovered, it will not display the warning message during a refactoring.

关于ASPX文件验证更新

在回答<一href="http://stackoverflow.com/questions/5809245/completely-remove-error-list-from-visual-studio/5809544#5809544">another 该问题是向我指出了验证ASPX文件将工作,如果显示实时语义错误启用了C#编辑器选项。这就解释了为什么我有问题,没有其他人似乎拥有。

When answering another question it was pointed out to me that validation for ASPX files will work if the "Show live semantic errors" option is enabled for the C# editor. This explains why I was having problems that nobody else seemed to be having.

推荐答案

现在的问题是,如果你有一个传统的asp.net网站,的.aspx和的.cs / VB codebehinds,是有实际的两个不同的参与集会。您的codebehind编译成一个程序集,和IIS将在.aspx和动态编译到另一个程序集。当您标记的东西内部定义的组件边界,从而动态ASPX组件不能引用内部成员在codebehind组装。

The problem is, if you have a traditional asp.net website with .aspx and .cs/vb codebehinds, is that there are actually two different assemblies involved. Your codebehind compiles to one assembly, and IIS will take the .aspx and compile it dynamically to another assembly. When you mark something as internal you define an assembly boundary, and thus the dynamic aspx assembly can't reference the internal member in the codebehind assembly.

现在,为什么它不工作一样,在VS的web服务器,我不知道,因为我不熟悉它的细节。然而,你可以做的就是在IIS中设置你的网站你的机器上。这样,它的行为完全一样的生产版本。

Now, as to why it doesn't work like that in VS's webserver I don't know as I'm not familiar with the particulars of it. However, what you can do is just set up your website in IIS on your machine. That way it will behave exactly like the "production" version.

如果你担心调试它,这是没有问题的,运行Visual Studio具有管理权限,并且当你的计算机上的服务器错误时,使用Visual Studio附加到w3wp.exe的,它会计算出来,打破错误。

If you're worried about debugging it, it's no problem, run Visual Studio with administrative rights, and when a server error on your machine occurs, attach to the w3wp.exe using Visual Studio and it'll figure it out and break on the error.

这篇关于编译在部署Web应用程序的错误,但不是在IDE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆