Asp.Net MVC How to prevent HttpCompileException exception - asp.net-mvc

In our production server there are sometimes an exception that occurs suddenly:
Error: System.Web.HttpCompileException (0x80004005): External component has thrown an exception
The solution is to clean the Asp.Net Temporary files or recycle the IIS pool.
But we don't know the reason for this exception, so that we can't prevent it happens in the future again and again, and this exception occurs one time in month approximately.
What could be the reason for it? And what is a good solution to handle it?

You can resolve these issues by upgrading to the .NET Framework 4.6.1
Alternatively, You can uninstall updates 3098779 and 3097997 if you have upgraded your system to the .NET Framework 4.6 or have installed Visual Studio 2015 from a fully updated .NET 4.5.1 or 4.5.2 system that has updates 3098779 and 3097997 installed.

Related

aspnetcore.dll failed to load

I usually dev on a windows 7 desktop, using visual studio 2015 update 3. I have the same vs2015.3 on my windows 10 laptop. I copied an asp mvc 5 app I am working on to the laptop but it wont run when I try to launch it from VS. I get the "aspnetcore.dll failed to load" error. I looked around and most solutions are to repair the asp net core install, but my laptop does not have asp net core installed on it, because I don't use core yet. My project is targeting .Net 4.6.
My desktop does have Core on it. So do I have to install .net core just because? Or is there some other solution? I am using the default IIS 10.
Found the solution - the applicationhost.config file had references to ASP.NET Core and was trying to load the non-existent module. I deleted the applicationhost.config file and reopened the solution, which forced VS to rebuild it without the ASP.NET Core references. Works fine now.
In my case with Visual Studio 2015, this file was located in .vs\config\applicationhost.config
For earlier versions of Visual Studio using IIS Express, see this question for more information about where applicationhost.config is located: Where is the IIS Express configuration / metabase file found?
Using VS 2015 (Windows 10). Working on a downloaded sample MVC app (from Intuit) targeting .net 4.6.1.
I was getting the exact same behaivior/error:
"The Module DLL C:\Program Files (x86)\IIS Express\aspnetcore.dll failed to load"
Locating the Applicationhost.config file (part of download package) and deleting it, did not solve the problem because IISExpress re-generated the Applicationhost.config file with the same references.
To solve the problem I had to comment out all the (aspnetcore.dll) references:
(configSections)
< section name="aspNetCore" overrideModeDefault="Allow" />
(globalModules)
< add name="AspNetCoreModule" image="%IIS_BIN%\aspnetcore.dll" />
(modules)
< add name="AspNetCoreModule" lockItem="true" />
You can do a search and comment out accordingly.
Installing the recently released Anniversary Update (version 1607) of Windows 10 seems to destabilize IIS by shutting down Application Pools, thus resulting in a 503 error when trying to run an application, which is caused by some DLLs failing to load when the worker process starts.
Check out the Windows Event Viewer (Win+X, V) to see what you need to fix: Open "Windows Logs", then "Application" and look for "Error" level entries with the source "IIS-W3SVC-WP" (may be different if the name of your IIS instance is not the default one). In the details, you will see a short message, like this:
The Module DLL <path-to-DLL> failed to load. The data is the error.
Depending on your configuration, there may be different DLLs causing this kind of problem and they will occur one by one, so you will need to keep checking the Event Logs and fix the issues until your application properly starts up. To be sure, before every attempt, stop IIS and close IIS Manager.
Here are two specific issues we've experienced so far and how to fix them, but you may bump into completely different ones:
1."C:\WINDOWS\system32\inetsrv\rewrite.dll" (reference) ◦Go to "Programs and Features" (Win+X, F) and repair "IIS URL Rewrite Module 2".
2."C:\WINDOWS\system32\inetsrv\aspnetcore.dll" (reference) ◦Go to "Programs and Features" (Win+X, F) and repair "Microsoft .NET Core 1.0.0 - VS 2015 Tooling ...".
Original source
For anyone coming to this later, what worked for me was this:
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-2.1&tabs=aspnetcore1x
I had to install the hosting runtime for aspnetcore (my team's using core) and that fixed my local IIS issues.
Deleting the applicationhost.config did not work for me.
My service was forced to run in 32bit mode, and my aspnetcore was 64 bit.
Since I'm currently not using .NET core I could comment out all references to aspnetcore in the applicationhost.config file and then restart iis.

Could not load file or assembly 'System.EnterpriseServices.Wrapper.dll' is not a valid Win32 application in MVC application

I am using MVC app having .net 4.5 and it was working fine in, 4 days back windows 10 update has happened and my IIS setting has gone.
After that i couldn't able to run my MVC app in Visual studio and it starts giving
Could not load file or assembly
'System.EnterpriseServices.Wrapper.dll' or one of its dependencies.
is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)
Every time, and don't understand what could be the reason, i searched so many posts, links, solutions are like moving dlls, etc.
Can somebody give my what is the reason and how can solve it
this might help system enterprice services error
Also, it might be worth re-installing the latest updates to Visual Studio as these often get corrupted on operating system updates.

Server error in Web Config of VS ASP.NET MVC Solution

I recently inherited am ASP.NET MVC website to hots on my server from a different team within the organization. The solution was built in VS 2012 and I am testing it in VS 2013 before I start hosting on the serer. There were a number of assembly dependency issues that I have fixed - I updated MVC in Nuget and also had to install and earlier version of EF (4.0.0.0) to get the solution to compile.
Now I am faced with another issue in the Web.Config file. The following screenshot presents the issue I am having:
There are only 3 scenarios that I can think of that is causing this which are the following:
1) Something happened when I updated MVC
2) Something happened when installed EF 4.0.0.0
3) The connection string to the old server is still in Web.Config
(the only reason I don't think this is the issue is because the
database it is calling is still in existance and the data is still
there)
I was hoping somebody with more experience with MVC and/or EF could help me troubleshoot this.

Visual Studio 2013 Ultimate Error while trying to debug an mvc application

I am developing a MVC web application. I had an issue where VS 2013 sp3 ultimate was not launching anymore so I uninstalled and re-installed VS 2013 sp4 ultimate. I am able to launch my web application using Start Without Debugging. However, when I try to debug my application I get a Microsoft Visual Studio pop-up error message that says:
Uncaught exception thrown by method called through Reflection.
It's not even reaching my application I am unable to even debug where this message is coming from.
I've already tried enabling 'Native Code' on all the included projects in my solution.
After several attempts to repair the final attempt solved the problem. Thank you.

Upgrade from .NET 4.5 MVC 4 to .NET 4.5.2 MVC 5.2

Almost the same scenario as before but this time I need to upgrade an app from .NET 4.5 (MVC 4) to 4.5.2 (MVC 5.2). I'd solved the previous issue by doing it on a Win 8 machine. It didn't work on Win 7.
Now, doing the same procedures (on a Win 8 machine) I have problems again.
I've followed the steps:
Upgraded all projects to Framework 4.5.2.
Checked for the Microsoft.AspNet.WebHelpers to uninstall it and it didn't exist.
Did the Manage NuGet Packages for Solution... step, and upgraded Microsoft.ASPNET MVC to 5.2 and Microsoft.ASPNET Web API to 2.2.
Edited all Web.Config files.
I've tried the Final Steps (Unload Project...) but the GUID was already gone.
The project builds fine but when I run it I get a Server Error page:
Attempt by security transparent method
'WebMatrix.WebData.PreApplicationStartCode.Start()' to access security
critical method 'System.Web.WebPages.Razor.WebPageRazorHost.AddGlobalImport(System.String)' failed.
I've tried all solutions that I found on the Net but no luck.
Is there anything else I need to do it because of the target versions 4.5.2/5.2?
UPDATE 1
Removed WebMatrix.Data and WebMatric.WebData. Now I get 403.14 error. The request hits Global.asax Application_PreRequestHandlerExecute method but it doesn't go into Application_Start.
I've solved it. I use Fluent Validation in the project and didn't update FluentValidation.MVC4 to MVC5.

Resources