locked
Could not load file or assembly 'System.Web.Http.WebHost, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified RRS feed

  • Question

  • User2038048451 posted

    Hi,

    I am getting below error with mvc.net web application, when I host in IIS. 

    Server Error in '/' Application.

    Could not load file or assembly 'System.Web.Http.WebHost, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

    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.IO.FileNotFoundException: Could not load file or assembly 'System.Web.Http.WebHost, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. 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.Http.WebHost, Version=5.2.3.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].

    i tried below approach, but still it does not work. 

    added below lines in runtime under web.config

    <dependentAssembly>
                <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Http.WebHost" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
            </dependentAssembly>

    Thursday, August 27, 2020 5:30 PM

All replies

  • User409696431 posted

    Try the suggestions from https://stackoverflow.com/questions/27250581/could-not-load-file-or-assembly-system-web-http-version-5-2-2-0 (adjusted for your version)

    Friday, August 28, 2020 5:03 AM
  • User-1330468790 posted

    Hi nrk_hi,

     

    Could you please confirm that which version of this assembly you included in the project?

     

    The error tells that the system could not load the file or assembly "System.Web.Http.WebHost, Version=5.2.3.0 ..." however you add the binding redirect element for "5.1.0.0".

     

    If you want to redirect the version binding to 5.1.0.0, you should modify the binding redirect element as below:

    From : Cover range from 0.0.0.0 - 5.1.0.0

    <dependentAssembly>
                <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Http.WebHost" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
            </dependentAssembly>

    To: Cover range from 0.0.0.0 - 5.2.3.0

    <dependentAssembly>
                <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.1.0.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Http.WebHost" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.1.0.0" />
            </dependentAssembly>

     

    Best regards,

    Sean

    Friday, August 28, 2020 5:42 AM