简体   繁体   中英

“aspnet_compiler.exe” exited with code 1" error when including ASP file

I have a ASP.NET project and when building the project it is showing build suceessfull. But when I am building the deployment project, it is showing build failed with an error message

Error    5    "aspnet_compiler.exe" exited with code 1

I rechecked my project and found that when i am removing the line <!--#include file="admin/topstyle.asp"--> , it is working fine. If I use this line, I am getting error building web deployment project to create my dll.

topstyle.asp is a file which render some common styles for the page like heading image and all.

Can anyone tell me how to get rid of this problem?

You can't mix ASP.NET and ASP in the same page. The ASP.NET compiler is returning an error because it doesn't understand the ASP code.

As for why the project builds okay, that's because include-directives are a function of the webserver, not Visual Studio or even ASP.NET. When you build in Visual Studio, the include is ignored because the compiler doesn't even know what it is (it just sees it as an HTML comment), so the compiler only sees the ASP.NET code and the HTML... but when the page is compiled on the fly, the webserver first brings in the included files and then passes the entire thing to the compiler, and the compiler then falls over when it encounters the included ASP code.

Following changes in vb.net code solved the Error "aspnet_compiler.exe" exited with code 1". The solution was build successfully but the publish failed.

The solution was build successfully but the PUBLISH FAILED with error "aspnet_compiler.exe" exited with code 1".

The Following changes in VB.NET code solved this error:

PREVIOUS CODE:

dtRow.Item("ParentGroupName") = Session("SecondaryGroupItems").GetSecondaryGroupItem(Session("LgItems").GetLgItem(mFnTransaction.FnTransactionDetails(1).LgId).SecondaryGroupId).Name

NEW CODE:

Dim mmSecondaryGroupId As Integer = 0
Dim mmLgId As Integer = 0

mmLgId = mFnTransaction.FnTransactionDetails(1).LgId

mmSecondaryGroupId = DirectCast(Session("LgItems"), LgItems).GetLgItem(mmLgId).SecondaryGroupId

dtRow.Item("ParentGroupName") = DirectCast(Session("SecondaryGroupItems"), SecondaryGroupItems).GetSecondaryGroupItem(mmSecondaryGroupId).Name

Does it work successfully on other pages? Also is the Topstyle.asp page a ASP.NET page? If not it will not work as you can't mix the two technologies like that.

In ASP.NET the include syntax is discouraged. Try using a user control instead, or the <%= Globals.MyConstantThatContainsTheStyles %>.

If you are using ASP 2.0 look at using Master Pages, but that might be a big change for your app.

I've found that the compiler sometimes has issues with absolute paths in include directives. Don't know if it solves this particular problem, but whenever possible, try to use <!-- include virtual="~/page.asp" --> instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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