Could not load EnterpriseLibrary assemblies when rendering view in MVC application - asp.net-mvc

When rendering a view in an ASP.NET MVC application, I am getting the following Yellow Screen of Death. It will occur only once during the server lifecycle, subsequent renders work fine. I don't have any references to EnterpriseLibrary 4.0.0.0 within the application itself, which makes me think that the reference is outside of my application (machine.config or something similar). I have checked for EnterpriseLibrary references in C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config and C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config but neither had any reference. Any ideas?
Thanks in advance.
EDIT: The error is occurring on the following line:
< asp:ScriptManager ID="ScriptManager2" EnablePartialRendering="false" runat="server" / >
., it previously appeared the error was occurring on the call to Telerik.
EDIT2: I can fix the error by removing < asp:ScriptManager ID="ScriptManager2" EnablePartialRendering="false" runat="server" /> which further points towards this being the problem. I am unsure as to why it is happening, however, and cannot claim I have an answer to the problem.
Here is the YSOD:
Server Error in '/services' Application.
--------------------------------------------------------------------------------
Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Configuration.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
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.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Configuration.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Source Error:
Line 153:<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
Line 154:
Line 155: < asp:ScriptManager ID="ScriptManager2" EnablePartialRendering="false" runat="server" / >
Line 156: <%= Html.Telerik().ScriptRegistrar() %>
Line 157:
Source File: c:\HIP\HWMI.API\HWMI.API.Web\Views\Membership\UserSubscriptionDetails.aspx Line: 155
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.Practices.EnterpriseLibrary.Configuration.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.
=== Pre-bind state information ===
LOG: User = HWI\jyoung
LOG: DisplayName = Microsoft.Practices.EnterpriseLibrary.Configuration.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/HIP/HWMI.API/HWMI.API.Web/
LOG: Initial PrivatePath = C:\HIP\HWMI.API\HWMI.API.Web\bin
Calling assembly : Microsoft.Practices.EnterpriseLibrary.Security.Cache.Configuration.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\HIP\HWMI.API\HWMI.API.Web\web.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.Practices.EnterpriseLibrary.Configuration.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Configuration.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) +0
System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +180
System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +192
System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) +115
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +426
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) +103
System.Reflection.RuntimeAssembly.GetCustomAttributes(Boolean inherit) +33
System.Web.UI.AssemblyCache.GetAjaxFrameworkAssemblyAttribute(Assembly assembly) +76
System.Web.UI.ScriptManager.get_DefaultAjaxFrameworkAssembly() +388
System.Web.UI.ScriptManager..ctor() +26
ASP.views_membership_usersubscriptiondetails_aspx.__BuildControlScriptManager2() in c:\HIP\HWMI.API\HWMI.API.Web\Views\Membership\UserSubscriptionDetails.aspx:155
ASP.views_membership_usersubscriptiondetails_aspx.__BuildControlContent3(Control __ctrl) in c:\HIP\HWMI.API\HWMI.API.Web\Views\Membership\UserSubscriptionDetails.aspx:153
System.Web.UI.CompiledTemplateBuilder.InstantiateIn(Control container) +12
System.Web.UI.MasterPage.InstantiateInContentPlaceHolder(Control contentPlaceHolder, ITemplate template) +87
ASP.views_shared_site_master.__BuildControlScriptContent() in c:\HIP\HWMI.API\HWMI.API.Web\Views\Shared\Site.Master:389
ASP.views_shared_site_master.__BuildControlTree(views_shared_site_master __ctrl) in c:\HIP\HWMI.API\HWMI.API.Web\Views\Shared\Site.Master:1
ASP.views_shared_site_master.FrameworkInitialize() in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\services\1a8554fb\b8d3a14c\App_Web_b1lugo2u.0.cs:0
System.Web.UI.UserControl.InitializeAsUserControlInternal() +35
System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) +8832342
System.Web.UI.Page.get_Master() +54
System.Web.UI.Page.ApplyMasterPage() +15
System.Web.UI.Page.PerformPreInit() +45
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +328
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

ASP.NET MVC does not support the ScriptManager object. This makes sense as the ScriptManager is a Web Forms element and does not fall into the MVC world. As to why IIS attempts to load unreferenced assemblies when the ScriptManager bombs, I still do not know. It seems to load whatever is in the BIN directory (I had left over EntLib 4.0 assemblies in BIN) but then continues to load beyond this. I stopped trying to get to the bottom of where it was loading from when IIS returned "Could not load file or assembly DeployLX.Licensing.v4." I fixed by removing all ScriptManager references from the MVC application, as they were not required anyhow. If I was to use them there is a MVC ScriptManager available http://mvcscriptmanager.codeplex.com/
tl;dr; MVC does not support ScriptManager. I removed it.

Related

'Object reference not set to an instance of an object' after successful deployment. ASP.NET MVC

My app works fine locally on debug and on release mode, but not on deployment.
I deployed the app on our server. and it works ok till I try to use the search function from one of my pages and receive 'Object reference not set to an instance of an object'. Search work perfectly fine locally.
this is the error that shows up:
[NullReferenceException: Object reference not set to an instance of an
object.]
Facility.Controllers.Filters.<>c__DisplayClass1_0.b__0(Notification
s) in
C:\LocalSVN\FacilityManagement\Facility\Controllers\Filters\NotificationsFilters.cs:52
System.Linq.WhereEnumerableIterator1.MoveNext() +122
System.Collections.Generic.List1..ctor(IEnumerable1 collection) +503
System.Linq.Enumerable.ToList(IEnumerable1 source) +69
AutoMapper.Mappers.EnumerableMapperBase`1.Map(ResolutionContext
context) +184 AutoMapper.MappingEngine.Map(ResolutionContext
context) +535
[AutoMapperMappingException:
Mapping types: IEnumerable1 -> IEnumerable1
System.Collections.Generic.IEnumerable1[[Facility.Model.Notification,
Facility.Model, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null]] ->
System.Collections.Generic.IEnumerable1[[Facility.ViewModels.NotificationListVM,
Facility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]
Destination path: IEnumerable`1
Is it something with linq or automapper? how do I solve this?
Checkout your deployment environment configuration, I believe your online db may have absent of the data, where your local db did not. This error message obviously told your code didn't handle how the null to be mapped in this case.

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.

Reference assemblies should not be loaded for execution

All of a sudden my website is throwing this error message when I try to debug it within Visual Studio. If I deploy the website, it works without any errors.
Any suggestions to resolve this error.
[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.Win32.Primitives' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)]
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) +531
[HttpException (0x80004005): Could not load file or assembly 'Microsoft.Win32.Primitives' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9946132
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +90
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261
Try delete that section from your web.config
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
</dependentAssembly>
Delete the \bin and \obj directories, Rebuild your project.
I had this problem, but with System.Runtime specified in the error message:
[BadImageFormatException: Could not load file or assembly 'System.Runtime' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)]
I found that thoroughly cleaning the solution and rebuilding fixed this problem for me. And just doing a Visual Studio Clean wasn't enough. I actually had to delete my \bin folders as well.
If you are working with .NET Core, and have this:
using System.Data.SqlClient;
Then, switching it to this is a potential solution:
using Microsoft.Data.SqlClient;
I noticed that my dll was only 1.0, and the error box said 4.0
I went back to NuGet Package Manager and put in System.Management.dll 4.0 —
no luck, then I just went back and put in System.Management.dll alone (as I remember), and it came up with a 5.0. Not exactly sure how I prompted it to do so, but it seemed quite willing.
Installed, works!
The same error happen in my case when I attach my DLL's from the "[build folder]\ref" folder.
It should be referenced from the [build folder]. (Net5)
i have deleted existing code based from local and again cloned the code. afterword its started working for me.

MVC 4 website on IIS7 - broken by minor changes (AutoMapper?)

I have a website built on ASP.NET MVC4, .NET 4.0
It is deployed on a server running IIS7.
I have done minor changes
Added AutoMapper (using nuget package) and used it in one of controllers
Added a new controller derived from ApiController (other ones were derived from Controller)
The site works well on my dev machine (both Cassini and IIS).
When I released the new version to the server, it did not work and showed the error page (below).
I am not sure what is the cause and how to fix it. Could you help me, please?
UPDATE 1
Version with ApiController but without AutoMapper works well.
Server Error in '/' Application.
Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
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.IO.FileLoadException: Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
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 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' 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:
[FileLoadException: Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)]
System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) +0
System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +493
System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +43
System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +325
System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) +208
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +1188
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean isDecoratedTargetSecurityTransparent) +36
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) +128
WebActivator.AssemblyExtensions.GetActivationAttributes(Assembly assembly) +114
WebActivator.ActivationManager.RunActivationMethods() +286
WebActivator.ActivationManager.RunPreStartMethods() +38
WebActivator.ActivationManager.Run() +56
[InvalidOperationException: The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047).]
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +691
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +425
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1021
[HttpException (0x80004005): The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047).]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +646
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +99
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +685
It was AutoMapper 3.0.0.
I have used AutoMapper 2.2.1 as suggested in
https://github.com/AutoMapper/AutoMapper/issues/383
and the problem was solved.

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

Resources