简体   繁体   English

构建网站时Visual Studio错误的错误?

[英]Visual studio erroneous errors when building a website?

Visual Studio 2008 shows a lot of erroneous errors when building a website (not a web project) in the errors list. 在错误列表中构建网站(而不是Web项目)时,Visual Studio 2008显示了许多错误错误。 These errors are usually corrected (removed) when I rebuild the site a couple times but they cost me wasted time. 当我重建网站几次时,通常会纠正(删除)这些错误,但这会浪费我的时间。

Is there anyway to hide the erroneous errors? 反正有没有隐藏错误的错误?

Update: I've decided to look into this to see if I could reproduce it. 更新:我决定调查一下,看看我是否可以重现它。 This is the exact behavior I am seeing, using the website model, I type some invalid syntax on a page. 这是我看到的确切行为,使用网站模型,我在页面上键入一些无效的语法。 The errors list fills up with errors. 错误列表填满了错误。 I correct the error and the errors list does not update. 我更正错误,错误列表不更新。 I build the project and the errors list still shows the errors but the build shows as build completed. 我构建项目,错误列表仍然显示错误,但构建显示为构建完成。 I build the project a second time and the errors list is cleared. 我第二次构建项目,并清除错误列表。

My question is there anyway to make the errors list clear on the first build? 我的问题是,无论如何要在第一次构建时清除错误列表? I thought it might have something to do with page build vs website build but it seems to make no difference. 我认为这可能与页面构建与网站构建有关,但似乎没有任何区别。 I am not using any third party dlls on this website. 我没有在这个网站上使用任何第三方dll。

This probably has to do with the way you reference your projects. 这可能与您引用项目的方式有关。 If you are referencing them as DLLs instead of projects, after a clean you will get missing reference/undef. 如果您将它们作为DLL而不是项目引用,那么在干净之后您将丢失reference / undef。 symbols errors until you build them. 符号错误,直到你构建它们。

I can't be sure that this is your case, but I have seen this be done before when you have multiple projects in your solution that have references to one another. 我不能确定这是你的情况,但我已经看到,在您的解决方案中有多个项目相互引用之前,这样做。 When doing so, your build order must be correct. 这样做时,您的构建顺序必须正确。 If this is the case, right-click on your solution in the Solution Explorer and select "Project Dependencies..." and make sure this looks right. 如果是这种情况,请在解决方案资源管理器中右键单击您的解决方案,然后选择“项目依赖项...”并确保其正确。

I've seen this exact problem in both VS2010 and 2012. 我在VS2010和2012都看到了这个确切的问题。

I think it's due to a combination of inappropriate file encoding and/or badly encoded characters in the web.config file. 我认为这是由于web.config文件中不适当的文件编码和/或编码错误的字符的组合。

I pasted a folder path into the value property of an appSetting entry without spotting it contained an ampersand. 我将文件夹路径粘贴到appSetting条目的value属性中,而不会发现它包含一个&符号。 The ampersand should of course have been encoded as "&". 当然,&符应编码为“&”。

The web.config file also had the "UTF-8 without signature" encoding. web.config文件还具有“UTF-8无签名”编码。 Although the VS IDE can work with this, it's not necessarily going to be understood by the .net compiler (see this answer: https://stackoverflow.com/a/8587278/1499294 ). 虽然VS IDE可以使用它,但是.net编译器不一定能理解它(参见这个答案: https//stackoverflow.com/a/8587278/1499294 )。

In Visual Studio you can change the file encoding by going to "Save [filename] As..." and clicking on the little down arrow on one end of the Save button. 在Visual Studio中,您可以通过转到“将[文件名]另存为...”并单击“ 保存”按钮一端的小向下箭头来更改文件编码。 The "UTF-8 with signature" (Codepage 65001) option seems to be a better bet. “具有签名的UTF-8” (代码页65001)选项似乎是更好的选择。

Without knowing what errors your are getting, this sounds maybe like you have some web server controls that are in a seperate project, and the order in which the projects are being compiled is causing the errors. 在不知道你得到什么错误的情况下,这听起来可能就像你有一些单独的项目中的Web服务器控件,以及编译项目的顺序导致错误。 Ie the main project is compiled, generates errors because it can't find web controls or other dependencies, and then the other projects are compiled, so that when you compile the second time the dependencies exist and the main project compiles successfully. 即主要项目被编译,生成错误,因为它无法找到Web控件或其他依赖项,然后编译其他项目,因此当您第二次编译时依赖项存在且主项目成功编译。

Edit: When you right click the Solution(not the project) in solution explorer, and choose Properties, there is a Project Dependencies page that lets you specify the dependencies of each project. 编辑:右键单击解决方案资源管理器中的解决方案(而不是项目),然后选择“属性”,可以使用“项目依赖关系”页面来指定每个项目的依赖关系。 Make sure that this is accurate in terms of what is using what. 确保这在使用什么方面是准确的。 Also be wary of circular dependencies. 还要警惕循环依赖。

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

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