External component has thrown an exception after framework upgrade on server - asp.net-mvc

I recently upgraded a 2008 R2 Web server to .Net Framework 4.6.1. I then installed my ASP.NET MVC application on such which is built to .Net Framework 4.6.1. When I attempt to run the site, I get the following error.
External component has thrown an exception.
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.Runtime.InteropServices.SEHException: External component has thrown an exception.
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:
[SEHException (0x80004005): External component has thrown an exception.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +485
System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) +190
System.Reflection.Assembly.LoadFrom(String assemblyFile) +54
WebActivator.ActivationManager.get_Assemblies() +244
WebActivator.ActivationManager.RunActivationMethods() +86
WebActivator.ActivationManager.RunPreStartMethods() +46
WebActivator.ActivationManager.Run() +68
[InvalidOperationException: The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: External component has thrown an exception..]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +900
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +164
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +169
System.Web.Compilation.BuildManager.ExecutePreAppStart() +172
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +907
[HttpException (0x80004005): The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: External component has thrown an exception..]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +579
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +118
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +726
I did same process on other similar servers and didn't hit an issue.
I did find that in IIS (which the site is running in), if I change the application pools "Load User Profile" setting to false then the site runs without a problem.
I don't just want to change this setting (unsure of its impact on the application), I would like to understand why I need to make such a change on this server and didn't need to on others. Was it the way the framework was installed or server is setup? Any feedback would be great.
(note: the server has version 4.5 installed and the site when built in such, ran without an issue)

I ran in this problem once, on many cases problem is due to some software in the dev suite that was not up to date. In my case the problem was caused due to Telerik justMock, The problem was resolved by updating justmock to latest version. Try to update or uninstall Telerik tools if you have one, Hope this solves your problem

External component has thrown an exception.
I had before similar problem after installing .Net Framework 4.6.1 - I have not figured out what component cause problem, but problem was related to missing .NET Framework 4.5.1 Targeting Pack.
Solution in my case:
uninstall all .NET Frameworks,
install .NET Framework 4.5.1 Developer Pack
install .NET Framework 4.5.2 Developer Pack
install .NET Framework 4.6.1 Targeting Pack
(the order is important)
All downloaded form official site: Targeting .NET Platforms

Related

Could not load file or assembly 'Autofac.Integration.ServiceFabric' or one of its dependencies

I am trying to run a service fabric project in visual studio 2015.
The following service fabric dependencies has been installed in the machine.
Microsoft Azure Service Fabric 5.6.210.9494
Microsoft Azure Service Fabric SDK 2.6.210.9494
Microsoft azure Service Fabric tools for Visual studio 1.6.50508.2
The project is getting build successfully. But while running the project the following error is occurring. The same dll is present in the machine. Please Help.
Could not load file or assembly 'Autofac.Integration.ServiceFabric' or one of its dependencies. An attempt was made to load a program with an incorrect format.
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.BadImageFormatException: Could not load file or assembly 'Autofac.Integration.ServiceFabric' or one of its dependencies. An attempt was made to load a program with an incorrect format.
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.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Autofac.Integration.ServiceFabric' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = Autofac.Integration.ServiceFabric
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Autofac.Integration.ServiceFabric | Domain ID: 3
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/A/MVCApp/WebApp/
LOG: Initial PrivatePath = C:\A\MVCApp\WebApp\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\A\MVCApp\WebApp\web.config
LOG: Using host configuration file: C:\Users\xxt\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/c767d98c/be7d29af/Autofac.Integration.ServiceFabric.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/c767d98c/be7d29af/Autofac.Integration.ServiceFabric/Autofac.Integration.ServiceFabric.DLL.
LOG: Attempting download of new URL file:///C:/A/MVCApp/WebApp/bin/Autofac.Integration.ServiceFabric.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
Stack Trace:
[BadImageFormatException: Could not load file or assembly 'Autofac.Integration.ServiceFabric' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +36
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +21
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38
[ConfigurationErrorsException: Could not load file or assembly 'Autofac.Integration.ServiceFabric' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +738
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +217
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +92
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +290
System.Web.Compilation.BuildManager.ExecutePreAppStart() +157
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +549
[HttpException (0x80004005): Could not load file or assembly 'Autofac.Integration.ServiceFabric' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10044672
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
Try to run this command on PM Console:
Install-Package Autofac.Integration.ServiceFabric
Note: If you want to completely remove the old Autofac.Integration.ServiceFabric references, you can remove them from Manage NuGet Packages>Installed Packages menu and then remove the related lines from packages.config file in your project. After that it will not comeback again during building of the project.

Could not load type 'ProtocolSupportModule'

I've found a boss-level error that forced me to become an active member of stackoverflow.
I am hosting an MVC app and on root level it works, however css and images are failing. Even when going to the image directly via URL I get the following error:
Could not load type 'ProtocolSupportModule'.
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.Web.HttpException: Could not load type 'ProtocolSupportModule'.
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:
[HttpException (0x80004005): Could not load type 'ProtocolSupportModule'.]
System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +12510809
System.Web.Configuration.HandlerFactoryCache.GetTypeWithAssert(String type) +47
System.Web.Configuration.HandlerFactoryCache.GetHandlerType(String type) +18
System.Web.Configuration.HandlerFactoryCache..ctor(String type) +27
System.Web.HttpApplication.GetFactory(String type) +94
System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +375
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
Okay so I figured this out.
Under handler mappings, the OptionsVerbHandler was set to allow all verbs under the request restrictions section. I set it to only allow the OPTIONS verb and created extra handlers for POST and GET.
UPDATE:
WHEN a GETHandler is specified on a folder with stylesheets or images the ProtocolSupportModule error occurs when the image/stylesheet is called. When no Gethandler is present on dll's views, the MVC app displays a verb rights error.
I got around this by setting the handlers on folder level. This is a bad way of doing it. Are there any better ideas? I am sure the MVC framework should handle this automatically?

Arithmetic operation resulted in an overflow

The application is working well in Win server 2003 /IIS 6.0 environment.
When I move the code to win server 2008/IIS 7.0 , I am getting below error? Could you advise what is the error cause? Did i missed anything?
Server Error in '/' Application.
Arithmetic operation resulted in an overflow.
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.OverflowException: Arithmetic operation resulted in an overflow.
Stack Trace:
[OverflowException: Arithmetic operation resulted in an overflow.]
System.IntPtr.ToInt32() +37
CoreLab.Common.a.a(Delegate A_0) +1935
CoreLab.Oracle.ab.a(OracleConnection A_0) +214
CoreLab.Oracle.OracleConnection.Open() +375
MonsterWorldwide.iTime.DataAccess.TimecardDA.GetTimecardPageInfoSet(Int32 personId, Int32 pageNumber, Int32 rowsPerPage, Int32& rowsCountTotal) in c:\inetpub\wwwroot\mtitimeproduction\dataaccess\timecardda.cs:28
MonsterWorldwide.iTime.BusinessLogic.TimecardBL.GetTimecardPageInfoSet(Int32 personId, Int32 pageNumber, Int32 rowsPerPage, Int32& rowsCountTotal) in c:\inetpub\wwwroot\mtitimeproduction\businesslogic\timecardbl.cs:24
MonsterWorldwide.iTime.WebGUI.WebParts.TimecardList.LoadData() in c:\inetpub\wwwroot\mtitimeproduction\webgui\webparts\timecardlist.ascx.cs:112
MonsterWorldwide.iTime.WebGUI.WebParts.TimecardList.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\mtitimeproduction\webgui\webparts\timecardlist.ascx.cs:52
System.Web.UI.Control.OnLoad(EventArgs e) +132
System.Web.UI.Control.LoadRecursive() +66
System.Web.UI.Control.LoadRecursive() +191
System.Web.UI.Control.LoadRecursive() +191
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428
Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4927
[OverflowException: Arithmetic operation resulted in an overflow.]
System.IntPtr.ToInt32() +37
CoreLab.Common.a.a(Delegate A_0) +1935
CoreLab.Oracle.ab.a(OracleConnection A_0) +214
This looks like some poorly written unmanaged interop code which doesn't take into account the CPU type and which blows when run in a x64 bit OS. In a 64-bit OS pointers are 64-bit integers contrary to 32 bit OS.
Maybe you should check the documentation of this CoreLab.Common component you are using whether it supports 64-bit systems.
Quote from the documentation of the IntPtr.ToInt32 method:
OverflowException: On a 64-bit platform, the value of this instance is too large or too small to represent as a 32-bit signed integer.

Could not load file or assembly 'Microsoft.JScript... or one of its dependencies... what gives?

What does this mean? This only happens on my local IIS where the site used to run fine no problem, it works fine on our DEV/QA servers but on my local machine I'm getting this, what gives? I had no knowledge of us using Microsoft.JScript ever, and doing a search of the project turns up nothing...
Could not load file or assembly 'Microsoft.JScript, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The module was expected to contain an assembly manifest.
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.BadImageFormatException: Could not load file or assembly 'Microsoft.JScript, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The module was expected to contain an assembly manifest.
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.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.JScript, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Stack Trace:
[BadImageFormatException: Could not load file or assembly 'Microsoft.JScript, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The module was expected to contain an assembly manifest.]
System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName) +0
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) +62
System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) +42
System.Type.GetType(String typeName) +65
System.CodeDom.Compiler.CompilerInfo.get_IsCodeDomProviderTypeValid() +13
System.Web.Compilation.CompilationUtil.GetRecompilationHash(CompilationSection ps) +3182
System.Web.Configuration.CompilationSection.get_RecompilationHash() +73
System.Web.Compilation.BuildManager.CheckTopLevelFilesUpToDate2(StandardDiskBuildResultCache diskCache) +684
System.Web.Compilation.BuildManager.CheckTopLevelFilesUpToDate(StandardDiskBuildResultCache diskCache) +50
System.Web.Compilation.BuildManager.Initialize() +320
System.Web.Compilation.BuildManager.InitializeBuildManager() +11203871
System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags) +498
[HttpException (0x80004005): Could not load file or assembly 'Microsoft.JScript, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The module was expected to contain an assembly manifest.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11301302
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +88
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4338644
UPDATE: This also happens when I try to browse ANYTHING through my local IIS, not just my web app! Though my web app isn't even using this thing at all... I can't even load up the ASP.NET configuration settings thing in the browser.
have you tried cleaning your solution?
Build -> Clean Solution
if that doesn't help closing visual studios, deleting everything in your bin folder ,then re-opening the solution, then do a re-build solution.
It could have relation to this bug which seems to be fixed by installing the SP2 for Windows Vista (if this is your case of course).
Another possible reason I can think of, although less probable, is that you are running a 64 bit OS and the assembly has been compiled for 32 bit. In this case you might try setting the application pool in IIS to enable 32 bit support:
To rule out this possibility you could check the processor architecture Microsoft.JScript assembly has been compiled against: MSIL, x86, x64
You should try to enable the assembly bind failure logging as describes in the error message. This should give you more information about what and why it is failing.
If this doesn't work for youthen you can try using proces monitor from msft. Procmon will tell you all of the files that your webserver is trying to load.
No posted solution worked and I needed to get it back up and running the next business day. Restored to factory default and re-installed everything, it only took about 4 hours of babysitting some restore software + putting VS, svn, filezilla, notepad++, sql manager back on.
Everything is working really great now :P

Problem with Deploying a ASP.NET MVC Project on a IIS 7.0. BadImageFormatException

I am stuck with my web application. As known from the title its a ASP.NET MVC(1,0) application so i do the only 2 things that a needed do deploy a application like this. I made a build an copied it to the IIS Folder. In the IDE (VS2008) all works fine :(.
This worked a long time. But know i get a error for my included dll of a other project.
(I have a German version so the Error is Translated from google sry for that)
BadImageFormatException: File or assembly 'DataService.WebInterface.BusinessLogic "or one of its dependencies was not found. An attempt was made to load a file with an incorrect format.]
System.Reflection.Assembly._nLoad (AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark & stackMark, throwOnFileNotFound Boolean, Boolean forIntrospection) +0
System.Reflection.Assembly.InternalLoad (AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark & stackMark, Boolean forIntrospection) +416
System.Reflection.Assembly.InternalLoad (String String assemblyName, Evidence assemblySecurity, StackCrawlMark & stackMark, Boolean forIntrospection) +166
System.Reflection.Assembly.Load (String string assemblyName) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper (String assemblyName, Boolean starDirective) +190
What does that mean? Is the File corrupted or do i have to change the web.config?
Thank your for your support!
This could mean that the project was targeted to different platform (x86/x64) than the server environment. Change the target platform in VS to match your server before publishing.
Apart from that there is a setting in iis manager in application pools -> advance settings named "Enable 32-Bit Applications" - change it to "True" if you use 32b bit assemblies (or native assemblies) on 64 bit environment.

Resources