Reputation: 3806
I have an ASP.NET MVC 5 project with the following in Web.config
<compilation debug="true" targetFramework="4.6.2">
and
<supportedRuntime version=".NETFramework,Version=v4.6.2" />
However, AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName
returns .NETFramework,Version=v4.5
rather than 4.6.2 on both IIS Express and IIS.
How do I make AppDomain load .NET 4.6.2 rather than 4.5?
Upvotes: 1
Views: 9456
Reputation: 3806
When upgrading the project from .NET 4.5 to .NET 4.6.2 via the project properties dialog, Visual Studio only change the compilation targetFramework
. However, the httpRuntime targetFramework
was left at 4.5.
compilation targetFramework="4.6.2"
compiles my code against .NET 4.6.2, but when IIS runs, it reads httpRuntime targetFramework="4.5"
and thus ran in .NET 4.5.
Upvotes: 3
Reputation: 4474
Are you running IIS in the same machine where 4.6.2 is installed? I think 4.6.2 may not be installed in the IIS installed server/machine. If you have already installed 4.6.2 in the server machine, then you can follow below steps to set the target framework in IIS.
To specify a .NET Framework version for an application pool
- Open IIS Manager. For information about opening IIS Manager, see Open IIS Manager (IIS 7).
- On the Connections pane, expand the server node and click Application Pools.
- On the Application Pools page, select the application pool for which you want to specify a .NET Framework version, and then click Basic Settings in the Actions pane.
- In the Edit Application Pool dialog box, in the .NET Framework version list, select the version that you want the application pool to use or select No Managed Code if the application uses only native code.
- Click OK.
Source :- Microsoft
Upvotes: 0