question

DuttaPijush-0082 avatar image
0 Votes"
DuttaPijush-0082 asked GeekDotnet answered

Conversion from .NET framework 4.6 to 4.8

I have converted my web api framework target from 4.6.2 --> 4.8, this is the error I get after I change target framework and reinstalling nuget packages:-

The type initializer for 'System.Web.Http.GlobalConfiguration' threw an exception.. error ASPRUNTIME.

My web config have information of old library and new as below:-

<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>

Can anyone suggest what is problem here. Thanks for help.

dotnet-runtimedotnet-aspnet-webapi
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

"The type initializer for 'System.Web.Http.GlobalConfiguration' threw an exception.. error ASPRUNTIME" is not enough. You need to edit the question to include the exact exception you got with full details.

0 Votes 0 ·
YijingSun-MSFT avatar image
0 Votes"
YijingSun-MSFT answered

Hi @DuttaPijush-0082,
As far as I think,there are two ways you could try:
1.Open ‘Package Manager Console’ and select the project present where WebAPI is present and run the following code:

 Install-Package Microsoft.AspNet.WebApi -IncludePrerelease

2.From ‘Manage NuGet Packages’ from Tools > NuGet Package Manager uninstall WebAPI libraries and reinstall WebAPI new libraries, where in you may find back missing libraries.

Best regards,
Yijing Sun


If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

GeekDotnet avatar image
0 Votes"
GeekDotnet answered

install Microsoft.AspNet.WebApi.Client 5.2.7 nuget package and try to run the app.

If this does not work, try commenting on this line.

<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.