Configuration error: System.Web.Helpers - asp.net-mvc-3

I deployed a site to a server and I get this error. Why do I get this?
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Source Error:
Line 16: <assemblies>
Line 17: <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Line 18: <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Line 19: <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Line 20: <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Source File: C:\<path>\web.config Line: 18
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 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].

Looks like the server on which you deployed the application doesn't have ASP.NET MVC 3 installed. If you do not want to install ASP.NET MVC 3 on the server you could also bin deploy your application.

I had the same problem and i installed ASP.NET MVC 3 Tools Update from Microsoft site and it resolved the problem.
Also check if the C:\Program Files (x86)\Microsoft ASP.NET is present prior to installation. As in my case this folder was missing and post installation i has this folder and assemblies got registered.

I had the following situation. A brand new laptop with Visual Studio 2015 working on a somewhat older MVC3 project. Visual Studio 2015 and later does apparently no longer install MVC 3. So after downloading the AspNetMVC3ToolsUpdateSetup.exe and installing it, the right references where found (from GAC). And the build completed with no errors, no extra steps needed besides this install.

As per the comments in Phil Haack's bin deploy post recent versions of Visual Studio don't have right-click Add Deployable Dependencies option on projects so you can do this:
Use the Package Manager Console and run the following command:
Install-Package Microsoft.AspNet.Mvc -Version 3.0.20105.1
That should reference all the assemblies in a manner that will make it
bin deployable.
I then got this error:
Could not load file or assembly 'NuGet.Core, Version=1.0.11220.104,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
dependencies.
Which I got rid of by deleting the file: bin\System.Web.WebPages.Administration.dll

Related

Visual Studio update 15.7.2 breaks Xamarin Android project

After updating Visual Studio, I can no longer build the release version of my Xamarin project:
1>Foobar.Android ->
C:\Apps\foobar-telerik-mobile-app\foobar\Android\bin\Release\foobar.Android.dll1>No
way to resolve conflict between "mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib,
Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e".
Choosing "mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" arbitrarily.1>The
"LinkAssemblies" task failed
unexpectedly.1>Mono.Linker.MarkException: Error processing method:
'System.Void
Telerik.XamarinForms.DataGrid.RadDataGridResourceDictionary::InitializeComponent()'
in assembly: 'Telerik.XamarinForms.DataGrid.dll' --->
Mono.Cecil.ResolutionException: Failed to resolve
System.Func`2
Xamarin.Forms.Internals.ResourceLoader::get_ResourceProvider()
If the Android option "Use Shared Runtime" is true, it will build - except you cannot publish with that option set! So there is no point.
I have no idea how to fix this. Any Microsoft/Xamarin/Telerik insiders out there with some ideas?

Team Foundation Server 2015 MsBuild 14

I am getting the following Conflict which doesn't make sense:
2>ResolveAssemblyReferences:
No way to resolve conflict
between "System.Web.Mvc, Version=5.2.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" and "System.Web.Mvc, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35". Choosing
"System.Web.Mvc, Version=5.2.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" arbitrarily.
No way to resolve conflict
between "System.Web.Mvc, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" and "System.Web.Mvc, Version=3.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35". Choosing
"System.Web.Mvc, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" arbitrarily.
Consider app.config
remapping of assembly "System.Web.Mvc, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" from Version "5.2.0.0" [] to Version
"5.2.3.0"
[C:\BuildAgent_work\1\s\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll]
to solve conflict and get rid of warning.
[warning]C:\Program Files
(x86)\MSBuild\14.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(1819,5):
Warning MSB3247: Found conflicts between different versions of the
same dependent assembly. In Visual Studio, double-click this warning
(or select it and press Enter) to fix the conflicts; otherwise, add
the following binding redirects to the "runtime" node in the
application configuration file:
The solution has 3 project and they all use Version=5.2.3.0. When i run local in Visual Studio I don't get this warning.
Any ideas how to fix it?
It seems your issue is because the assembly on your local machine and build agent machine are different. You can try to remove/uninstall the assemblies and reinstall them from Manage Nuget Packages, the warning should disappear.

AjaxControlToolkit Version=4.1.60501.0 - Error: AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts

I'm getting this error:
Error: AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts. Ensure the correct version of the scripts are referenced. If you are using an ASP.NET ScriptManager, switch to the ToolkitScriptManager in AjaxControlToolkit.dll.
I've searched Hi and Low and can not resolve this. When I went to VS2008 I had the same issue and resolved it with changing my web.config
Now I ma running VS 2012 express. I've installed AjaxControlToolkit version 4.1.60501.0
Web.config:
<compilation debug="false" targetFramework="4.5">
<assemblies>
<add assembly="AjaxControlToolkit, Version=4.1.60501.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
and
<controls>
<add tagPrefix="cc1" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>
</controls>
In ASPX I have:
<cc1:ToolkitScriptManager ID="ScriptManager1" runat="server">
</cc1:ToolkitScriptManager>
And I'm getting the above error. I know the Toolkit DLL is the correct version.
I am also running VS2008 / Ajax 3.5 on the same machine, but I cleared out the Temporary ASP.Net Files folder of all other projects and still have the issue. When I run this new VS2012 project, a ROOT folder is created in the in the Temp folder and the AjaxControlToolkit.DLL in that folder is version 4.1.60501.0
What needs to change?
Thanks Much,
Jim

ViewBag.Title error

Working against the current RC2 - the template that is generated Razor views includes:
#{
ViewBag.Title = "Details1";
Layout = "/Views/Shared/_Public.cshtml";
}
With a red squiggly under ViewBag.Title and this compiler error:'
Error 4 One or more types required to compile a dynamic expression cannot be found. Are you missing references to Microsoft.CSharp.dll and System.Core.dll? c:\Visual Studio 2010\Projects\myProj\Views\Webinar\Details1.cshtml 6 2 TTSTrain.Webinars.WebEntry
But the project builds and functions correctly. Is the error indicative of other problems that should be addressed?
I got the same problem after I removed the targetFramework attribute from the <compilation> element in the Web.config file.
Once I restored it to
<compilation debug="true" targetFramework="4.0">
Everything worked fine again!
I solved it in the following way:
First i noticed using gacutil (Global Assembly Cache Utility) that it contained two references to System.Core, one to version 4.0 and one to version 3.5. Apparently inside the razor views, even if in the project i had the correct reference to version 4.0, it was still using version 3.5 and that's why i was getting the error about the dynamic types.
To check if that's your case open as administrator Visual Studio Command Prompt and execute:
gacutil -l System.Core
To remove the reference to the old version of System.Core i did the following steps:
- cd %systemroot%\assembly\
From here you may have more that one "gac" directory, so you will have to search within each to find your component. For me, it was within the "gac_MSIL" directory.
- cd gac_msil
- cd System.Core
- cd <assembly version number>__<public key token>
- erase *.* Say "y" to are you sure.
- cd ..
- rd <assembly version number>__<public key token>
- cd ..
- rd System.Core
After that I opened my solution again in visual studio and the error was gone, it references properly to System.Core 4.0 and I was not getting the dynamic errors anymore :)
I hope it will help you as well,
Best, N.
Similar to #Kaiser's answer, I experienced this problem as a result of having multiple System.Core assemblies in the GAC.
I chose not to delete the 3.5 assembly, however. Instead, in the Views web.config, I modified the configuration/system.web/compilation node as follows:
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</assemblies>
</compilation>
The important line is the last assembly node: it tells the Razor compiler which GAC assembly version to use.
Once I did this, all was well in my Razor views.
I do not have this problem when running VS 2012 as administrator.
Otherwise, what worked for me:
in root web config have added as recommended reference to correct assembly as child of compilation node`
<system.web>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
</system.web>
set copy local = true properties for System.Core and Microsoft.CSharp`
Do you have a reference to Microsoft.CSharp and System.Core?
MVC Views (usually) get compiled dynamically when you access your site, not when you compile the application in VS. I imagine you will see issues when running the site. Just add the two references and you should be fine.
By using Peters answer i managed to solve the issue with Html.EditorFor(m => m.xxx) underline errors in the chtml files.
Althought the ViewBar error persisted.
So i changed the web.config like this
<compilation debug="true" targetFramework="4.5.1">
<assemblies>
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add assembly="Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</assemblies>
</compilation>
Notice the Microsoft.Csharp line.
The above did the trick and now the chtml editor is clear from the red underlines.
Thanks Peter
I had the exact same problem. By default, when you create an MVC3 app it sticks a web.debug.config and a web.release.config in the solution. When I got rid of those two items, the ViewBag issue resolved itself. It may have something to do with what Peter was saying above but I didn't test that.
That is the time when other fields in ViewBag is read. So if you are passing them from controller.
ViewBag.yourobjectDto = yourObjectDto;
make sure this line is not blocked through if condition or something.
Try
Page.Title = "Details1";
It might work.

Could not load file or assembly 'System.Web.Ajax, Version=3.0.31106.0

HI folks,
I have a .net application (vb.net) and I'm using the ajax control toolkit. It works fine on my production machine but when I upload it to the host (fasthosts) i get this error:
Could not load file or assembly 'System.Web.Ajax, Version=3.0.31106.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' 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 'System.Web.Ajax, Version=3.0.31106.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' 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 'System.Web.Ajax, Version=3.0.31106.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' 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 'System.Web.Ajax, Version=3.0.31106.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' or one of its dependencies. The module was expected to contain an assembly manifest.]
AjaxControlToolkit.ToolkitScriptManager.ApplyAssembly(ScriptReference script, Boolean isComposite) +0
AjaxControlToolkit.ToolkitScriptManager.OnResolveScriptReference(ScriptReferenceEventArgs e) +167
System.Web.UI.ScriptManager.RegisterScripts() +191
System.Web.UI.ScriptManager.OnPagePreRenderComplete(Object sender, EventArgs e) +113
System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +8698462
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1029
Here is my web.conf file. Its very simple:
<system.web>
<customErrors mode="Off"/>
<compilation debug="true">
<assemblies>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation></system.web>
Does anyone know whats up?
-- Billy
In order to use ASP.NET AJAX, you would have installed the ASP.NET AJAX framework on your machine, which includes this DLL that is causing the error.
The chances are that your hosting company doesn't have ASP.NET AJAX installed.
This post is old but just in case someone else needs help in this issue. Below are 3 easy steps to fixing it:
Step 1: Download the latest ajax toolkit from Codeplex.com.
Step 2: Extract the zip file. (Optional) --> Google the net on how to add the new ajax controls to your Toolbox. It is also simple.
Step 3: Copy and paste all the contents of the extracted folder to the BIN folder of your project.
Rebuild and run it.

Resources