Niels Filter
Niels Filter

Reputation: 4528

MVC System.Web.HttpCompileException on Html.RenderPartial

I'm getting an System.Web.HttpCompileException when the my view calls Html.RederPartial. The exception message is:

Additional information: External component has thrown an exception.

I've checked that the:

The exception sounds like it should be that the html or razor is malformed or incorrect, but the solution builds fine. It was also working not too long ago, so I'm guessing, I'm missing something silly...

My question:

Does anyone know how to know what causes this exception? Or is there a way to get more information on the exception?

Edit: Here's the StackTrace

at System.Web.Compilation.AssemblyBuilder.Compile() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean ...

Upvotes: 9

Views: 18404

Answers (3)

CsK
CsK

Reputation: 39

We resolved " External component has thrown an exception." issue by recycling the application pool. It is quick method before doing else.

Upvotes: 0

Omkar Manjare
Omkar Manjare

Reputation: 53

I found one of my HTML partial i.e. *.cshtml file was missing references. Generally when any cshtml page having error on it, is not shown at compile time though you can track it with debug points

Upvotes: 0

Niels Filter
Niels Filter

Reputation: 4528

Turns out it was a silly mistake on my part. MVC couldn't compile the Html from Razor because I had renamed a property within my Model, but didn't update it in the .cshtml.

Turn on Razor Build errors at compile time. Edit your csproj file and set the following:

<MvcBuildViews>true</MvcBuildViews>

Thanks to JP for this SO post.

Upvotes: 26

Related Questions