views:

304

answers:

4

I have a strange problem when I publish my website. I inherited this project and the problem started before I arrived so I don't know what conditions lead to the creation of the problem.

Basically, 3 folders below the website project fail to publish properly. When the PrecompiledWeb is transferred to the host these three folders have to be manually copied from the Visual Studio project (i.e. they are no longer the published versions) to the host for it to work.

If the results of the publish operation are left, any page in the folder results in the following error:

Server Error in '/' Application. Unable to cast object of type 'System.Web.Compilation.BuildResultNoCompilePage' to type 'System.Web.Compilation.BuildResultCompiledType'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Unable to cast object of type 'System.Web.Compilation.BuildResultNoCompilePage' to type 'System.Web.Compilation.BuildResultCompiledType'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidCastException: Unable to cast object of type 'System.Web.Compilation.BuildResultNoCompilePage' to type 'System.Web.Compilation.BuildResultCompiledType'.] System.Web.UI.PageParser.GetCompiledPageInstance(VirtualPath virtualPath, String inputFile, HttpContext context) +254
System.Web.UI.PageParser.GetCompiledPageInstance(String virtualPath, String inputFile, HttpContext context) +171
URLRewrite.URLRewriter.ProcessRequest(HttpContext context) +2183
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +405 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +65

Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832

Does anyone have any idea what the possible causes of these pages not publishing correctly could be? Anything I can look at that may indicate the root of the problem?

Addition: It is a completely clean build each time, so there shouldn't be a problem with old bin files lying around. I've also checked the datestamp on the items in the bin folder and they are up-to-date.

Second Addition: The project was originally created as a Web Site, not a Web Application. Sorry for the ambiguity.

A: 

I would try cleaning the bin\ folder. In any case our shop completely dropped websites in favour of web form applications, which are arguably far better.

EDIT: Migration HOW TO here

Sklivvz
Done that - Unfortunately it didn't do any good. Also, I was not around when the project started so I didn't have any control on the project types.
Colin Mackay
You can easily convert from websites to web applications using a tool on ScottGu's blog (or maybe is also in VS2005 SP1?). Seriously, this is how I generally solve these issues!!!
Sklivvz
I might try that in isolation - However, we are a week away from go-live and I don't want the risk of introducing any other unforseen problems at this stage.
Colin Mackay
For anyone else reading this post, the migration process is described here: http://webproject.scottgu.com/CSharp/Migration2/Migration2.aspx
Colin Mackay
Added to the post. I understand that you want to have confidence, but I've never had a problem.
Sklivvz
+1  A: 

You might look into trying Microsoft's Web Deployment Projects. They give you much more control over MSBuild, essentially, but it might help solve your deployment/pre-compiling woes.

Are we to infer you are using a Web Site project type (and not Web Application)?

Yadyn
I'll look into Web Deployment Projects. Also, yes, it is a Web Site project, not a Web Application project.
Colin Mackay
+1  A: 

Im guessing that because when you publish, it is compiling your Web Site project and it is hitting a duplicate class name somewhere across different folders or sub folders. Make sure you check your inherit tags and class names so that you dont call 2 classes the same thing. This is fine and wont error when it happens in different folders when coding and debugging, but when you go to publish / deploy it will error. ... Hope that makes sense.

Mcbeev
I've added namespaces to each of the classes in the affected folders to ensure a unique name in case there was a clash I wasn't aware of. However, now that I've had a chance to test it, it still didn't work.
Colin Mackay
A: 

I had a similar problem a while back, where the publish would say it was successful, but the publish folder remained empty.

Besides looking at the Web Deployment Projects you should also set the verbosity to Diagnostic (Tools=> Options=>Project and Solutions =>Build and Run=> Msbuild project build output verbosity)

This, in my case had the effect of displaying meaningful compiler errors that helped me resolve the issue.

You could then also run the aspnet_compiler with the -errorstack directive in the shell prompt to display additional errors.

Mircea Grelus