c# - Cannot load file after installing CORS -


i have created basic asp.net web api application inside vs express 2013 using of defaults. added controller , returns xml want.

as install cors package:

install-package microsoft.aspnet.webapi.cors -pre 

i can't run application anymore:

an exception of type 'system.io.fileloadexception' occurred in mscorlib.dll , wasn't handled before managed/native boundary  additional information: not load file or assembly 'system.web.http, version=5.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35' or 1 of dependencies. located assembly's manifest definition not match assembly reference. (exception hresult: 0x80131040) 

i followed of instructions on blog post: http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api says nothing issue.

i tried updating web api with:

install-package microsoft.aspnet.webapi -pre 

but still problem persists unfortunately

in project using webapi.hal depends on web.api 5.0 , greater. there breaking changes perhaps?

absolute minimum reproduce problem

  1. create new, empty, web api project n vs express web 2013
  2. add controller , test works
  3. install cors
  4. file load error - controller doesn't work anymore
  5. upgrade web api - fixes problem

    install-package microsoft.aspnet.webapi -pre

  6. install webapi.hal - breaks same error again

can use old version of cors library doesn't kill else?

detailed stack trace

=== pre-bind state information === log: displayname = system.net.http.formatting, version=5.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35  (fully-specified) log: appbase = file:///c: log: initial privatepath = c calling assembly : webapi.hal, version=2.2.0.18, culture=neutral, publickeytoken=null. === log: bind starts in default load context. log: using application configuration file: c: log: using host configuration file: c:\ log: using machine configuration file c:\windows\microsoft.net\framework\v4.0.30319\config\machine.config. log: post-policy reference: system.net.http.formatting, version=5.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35 log: attempting download of new url file:///c: files/root/aa0e7960/9dfdb45e/system.net.http.formatting.dll. log: attempting download of new url file:///c: files/root/aa0e7960/9dfdb45e/system.net.http.formatting/system.net.http.formatting.dll. log: attempting download of new url file:///c:/corstest/corstest/bin/system.net.http.formatting.dll. wrn: comparing assembly name resulted in mismatch: minor version err: failed complete setup of assembly (hr = 0x80131040). probing terminated. 

two step fix problem

  1. add

    dependentassembly assemblyidentity name="system.web.http" publickeytoken="31bf3856ad364e35" bindingredirect oldversion="0.0.0.0-5.0.0.0" newversion="5.0.0.0" dependentassembly

to web.config

  1. go tool/library packed manager/manage nuget package solution , click microsoft asp.net mvc , click update.

hope help

tam nguyen


Comments

Popular posts from this blog

php - Magento - Deleted Base url key -

javascript - Tooltipster plugin not firing jquery function when button or any click even occur -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -