Install ASP.NET MVC 4.0.4 - asp.net

I have a production server for a project, and I try to build a test server for the same project with the same environment.
For this, I need to install on the test server (that means, no VS or any dev stuff like package managers, etc.) the same version installed on the prod server version of ASP.NET MVC: 4.0.4xxx.
I searched to download the latest ASP.NET MVC 4 installer, and the only download MS proposes is the ASP.NET MVC 4 for Visual Studio 2010 SP1 (don't really understand what has to do here VS 2010 - should it work only with VS?!) - once installed I navigate to C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies and the System.Web.Mvc.dll version is 4.0.207xxx.
Where could I find the ASP.NET MVC 4.0.4xxx?
More info:
the .NET installed is
the ASP.NET seems to be 4.0.0.0:
also
Finally, in localhost, I get the following error:

Since ASP.NET MVC version 3.0.20105.1, the Microsoft.AspNet.Mvc DLL has been available through NuGet. This means your application should include Microsoft.AspNet.Mvc version 4.0.40804 as part of its distribution (in the bin folder) when your application is published.
The only thing you need to install on a production or test server is the .NET Framework Redistributable 4.0+ in order for ASP.NET MVC 4 to function.
Do note that .NET Framework 4.0 is no longer supported, so it is recommended to use at least Microsoft .NET Framework 4.5.2. All versions of .NET Framework 4.0+ are in-place upgrades, so all higher versions should work with your application without any changes.
There was also a security update that broke compatibility with 4.0.0.0, that will need to be applied to your server if it is not already installed. This updates MVC 4 assembly version from 4.0.0.0 to 4.0.0.1, so it is a breaking change for applications that are compiled against 4.0.0.0. Since your application is looking for 4.0.0.1 (as it should) that means your application is compiled with the security update, but the server needs the security update for MVC 4 installed.

Related

Error System.NotSupportedException on Razor Pages Project

After researching a lot and finding nothing about it, I decided to ask for collaboration here in the community.
I am trying to perform run in Visual Studio 2019 from a Razor Pages project, created in the 2017 version of Visual Studio. The Target Framework is net461.
However, the following error occurs:
NotSupportedException: Attempting to load an assembly from a network
location that would cause the assembly to be in safe mode in earlier
versions of the .NET Framework. This version of the .NET Framework
does not enable CAS policy by default, so this loading can be
dangerous. If it does not intend to confine the assembly, enable the
loadFromRemoteSources option.
I am not loading any assemblies over the network. All files are on my computer. Also, all exe, dll files are unlocked.
Error is in the startup.cs:
services.AddMvc()
I greatly appreciate any help.
are you creating .NET 4.6.* project or .Net Core? For .Net Core the target framework should be .NET Core 2.* or 3.* and make sure SDK is installed on your machine.

Asp.Net Core 2.1 with .Net Framework 4.6.1 error after deployment using dotnet publish or visual studio publish

I am trying to deploy Asp.Net Core 2.1 application with target framework 4.6.1 on server. I am using dotnet publish command and copying the publish folder on the server where deployment is intended. Everything works fine on local machine. But when I am trying to run the application on the server , it is throwing the exception ".Net Framework 4.6.1 not installed, please install it.".
I thought .Net framework is not installed but when I checked installed software , I can see .Net 4.6.1 is installed. Not sure why the error is occurring.
Here is screenshot for the application error and installed software
That error is odd, since you do indeed seem to have that version installed. However, I believe it may be a red herring. I haven't personally tried to run ASP.NET Core 2.1 on .NET Framework, but I suspect it may not work at the moment. The full framework support depends on .NET Standard compatibility which only goes up to .NET Core 2.0. (With .NET Standard 2.0). ASP.NET Core requires .NET Core 2.1. You can try targeting a later version of .NET Framework - something recent like 4.7.2. You may need to downgrade to ASP.NET Core 2.0, if you need to target .NET Framework.
Your list only shows development packages to support targeting and developing for .NET Framework 4.6.1
See How to: Determine which .NET Framework versions are installed for ways to check the .NET Framework version on the machine.

Do .NET Core apps require the .NET runtime installed on the target machine?

In this video, Scott Hanselman interviews a guy from the ASP.NET team. He says that one of the goals of ASP.NET 5, on top of .NET Core, is that the apps won't depend on the .NET Framework and GAC assemblies on the hosting server. Instead, .NET Core libraries will be released via NuGet packages and apps will be deployed with their dependencies.
One of the reasons for this is so Microsoft can quickly release a bug fix or new feature, and we don't have to wait until the new version (of the full framework) is installed on our hosting environment.
My question is:
Are the apps built on .NET Core really independent of the version of .NET installed on the target machine, and can they run even without the .NET Framework installed?
Yes, the framework you use in your application is completely independent of the .NET Framework installed on the target server, because the Core .NET Framework is referenced via NuGet packages and can be bundled up for deployment via the DNX Utility, specifically of interest to you will be the dnu publish command.
Here is an excerpt, describing what dnu publish does:
Publish (dnu publish)
The publish command will package your application into a self-contained directory that can be launched. It will create the following directory structure:
output/
output/packages
output/appName
output/commandName.cmd
The packages directory contains all the packages your application needs to run.
The appName directory will contain all of your applications code, if you have project references they will appear as their own directory with code at this level as well.
So the .NET Core will exist in the output/packages directory and will not need to be installed on the target server.
A normal .net core app requires that you install .net core on the machine you wish to run the application on. There is a way to avoid this however, by publishing a self contained app. You can publish your app with the requisite version of .net core included. This will make your app larger, but if you only need one application on a machine to run .net, you need a specific version of .net, or you want to make a portable application, this is a good choice.

ASP.NET compiler fails with an XmlSerializers error, during web-deployment project

We're using Visual Studio 2010 Web deployment projects to compile web-application websites during our build. Visual Studio 2010 is not installed on our build-agents. We get an error (see below) during the build relating to the automatically-generated Foo.XmlSerializers.dll being built with a runtime newer than the currently loaded runtime and cannot be loaded by aspnet_compiler.exe.
We're targeting .NET Framework v3.5 in our project files.
Here's the error (reformatted for long lines):
"C:\BuildAgent\work\3836706d661b8a05\project\src\Foo.FrontEnd.WdpSite\
Foo.FrontEnd.WdpSite.wdproj" (Build target) (1) ->
(AspNetCompiler target) ->
ASPNETCOMPILER : error ASPCONFIG: Could not load file or assembly
'Foo.FrontEnd.Site.XmlSerializers' or one of its dependencies.
This assembly is built by a runtime newer than the currently loaded
runtime and cannot be loaded.
[C:\BuildAgent\work\3836706d661b8a05\project\src\Foo.FrontEnd.WdpSite\
Foo.FrontEnd.WdpSite.wdproj]
I was having a similar issue, with the same error message, and after lots of frustration found the solution (which hopefully will give some ideas for this).
Here we have a build server with Windows SDK 7.1 (and 6.1 from when using Vs 2008) building VS 2010 projects targeting .NET 3.5. The web projects are then pre-compiled with aspnet_compiler (from v2 as per http://msdn.microsoft.com/en-us/library/ms229863.aspx#findingthecorrectversion). During pre-compilation I received the same error message as yourself for a project (not web, just normal library) with a web reference to a web-service. It looks like Windows SDK 7.1 doesn't set up the registry paths correctly for using .NET 3.5 tools (while Visual Studio does). This caused the web references to be compiled with a target runtime of .NET 4 (validated using reflector) so aspnet_compiler v2 had a fit. I compared the registry settings of the build server and my local visual studio install which showed the .NET 3.5 configuration for SDK 7.1 was not good, so I corrected the build server with the below. My guess is the web reference xml (in the non-web project) was being precompiled with sgen for .NET 4 as a fall back for not using the correct .NET 3.5 sgen. Once the registry change was applied everything was fine (the below didn't exist in my build server registry so I created it).
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1\WinSDK-NetFx35Tools-x86]
"ComponentName"="Windows SDK .NET Framework 3.5 Multi-targeting Utilities"
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\bin\\"
"ProductVersion"="7.1.7600.0.30514"
Just as an aditional note I also used WindowsSdkVer to set 7.1 as the default SDK.

Error: This assembly is built by a runtime newer than the currently loaded runtime

I have downloaded published (code behind files are no there, combined with dll in bin folder) web application from Window Server 2008 where it is hosted, and open it with Visual Studio when I debug that application it shows following error:
"Could not load assembly because this assembly is built by a runtime newer than the currently loaded runtime"
I don't know how can I solve this problem and test application locally.
Please help me.
This errors happens when the DotNet framework you are using is of older version than the one used to build the assembly. You need to check which version of framework is used to build those assemblies and then use the same or higher to debug too.
I was getting this same error when running an installer for a Windows service, even when running the installer on the PC the installer was built on.
It turned out that although the Windows service project had been updated to .NET 4.5, the Setup project that was making the installer was still set to use .NET 2.0.
To check if the Setup project is using an older version of .NET than the project to be installed, in the Visual Studio Solution Explorer:
Expand the Setup project;
Under the Setup project, expand Detected Dependencies;
Under Detected Dependencies select Microsoft .NET Framework and check the Version property. Select the appropriate .NET version from the dropdown list;
Re-build the Setup project to create a new version of the installer.
This error can have a lot of other reasons, too. I had the same problem, and nothing helped until I stumbled across this:
TlbExp.exe error:This assembly is built by a runtime newer
I just ran into this issue when the assembly was built with a target framework of .NET 4, and v4.0.30319 was installed on the server, and other 4.0 apps were running successfully.
The problem arose because the app had originally been built targeting 2.0, and new 4.0 assemblies were pushed, but not the app.config file, which we generally update separately.
This means the supportedRuntime attribute was not updated in the config and caused the error. Adding the following to the app.config fixed our issue:
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
One the the assemblies reference in the project might be built using a newer version of .net, check version of every assembly reference and correct accordingly.
Also check the application pool that this web site is running as. It could be framework 2.0 default on some older windows servers. Change it to framework 4.0.

Resources