David Shochet
David Shochet

Reputation: 5395

Cannot load file or assembly 'System.Runtime'

I have an Asp.Net 4.7 WebForms legacy application written in vb.net. To add Azure B2C authentication, I add OWIN middleware NuGet packages like this:

Install-Package Microsoft.Owin.Security.OpenIdConnect

Install-Package Microsoft.Owin.Security.Cookies

Install-Package Microsoft.Owin.Host.SystemWeb

based on this tutorial: https://learn.microsoft.com/en-us/azure/active-directory/develop/tutorial-v2-asp-webapp

When I try to run the application, I get this error:

Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Here is the log:

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll Running under executable C:\Program Files\IIS Express\iisexpress.exe --- A detailed error log follows.

=== Pre-bind state information === LOG: DisplayName = System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=... (Fully-specified)

LOG: Appbase = file:///C:/Git Repos/InfoWeb/

LOG: Initial PrivatePath = C:\Git Repos\InfoWeb\bin Calling assembly : System.Net.Http.Primitives, Version=4.2.29.0, Culture=neutral, PublicKeyToken=....

=== LOG: This bind starts in default load context.

LOG: Using application configuration file: C:\Git Repos\InfoWeb\web.config

LOG: Using host configuration file: C:\Users\dreznik\OneDrive - MyCompany\Documents\IISExpress\config\aspnet.config

LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.

LOG: Redirect found in application configuration file: 4.0.0.0 redirected to 4.1.1.0.

LOG: Post-policy reference: System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=...

LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/vs/17153f21/a2ffde83/System.Runtime.DLL.

LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/vs/17153f21/a2ffde83/System.Runtime/System.Runtime.DLL.

LOG: Attempting download of new URL file:///C:/Git Repos/InfoWeb/bin/System.Runtime.DLL.

LOG: Attempting download of new URL file:///C:/Git Repos/InfoWeb/bin/System.Runtime/System.Runtime.DLL.

LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/vs/17153f21/a2ffde83/System.Runtime.EXE.

LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/vs/17153f21/a2ffde83/System.Runtime/System.Runtime.EXE.

LOG: Attempting download of new URL file:///C:/Git Repos/InfoWeb/bin/System.Runtime.EXE.

LOG: Attempting download of new URL file:///C:/Git Repos/InfoWeb/bin/System.Runtime/System.Runtime.EXE.

How can this be resolved? I have already tried to delete temporary Asp.Net files.

Upvotes: 1

Views: 1254

Answers (1)

Reza Kia
Reza Kia

Reputation: 435

You must check that assemblyBinding subsection inside runtime section of web.config file have correct value that define System.Runtime.

It must be something like this

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
            <bindingRedirect oldVersion="4.0.0.0-4.0.0.0" newVersion="6.0.0.0" />
        </dependentAssembly>
    </assemblyBinding>
</runtime

Upvotes: 1

Related Questions