Repro steps:
- Create MVC4 Web API project and add web api controller
- Install OData package from latest myget feed: http://www.myget.org/F/aspnetwebstacknightly/
- Apply [Queryable] to get action
- Create unit test project
- Add project reference to previous one and add OData package from myget feed
-
Add test code:
[TestMethod]
public void TestMethod1()
{
var config = new HttpConfiguration();
config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
WebApiConfig.Register(config);
var server = new HttpServer(config);
HttpClient client = new HttpClient(server);
var response = client.GetAsync("http://localhost/api/Blah").Result;
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
}
- Run it and it reports error:
System.IO.FileLoadException occurred
HResult=-2146234304
Message=Could not load file or assembly 'Microsoft.Data.Edm, Version=5.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source=System.Web.Http.OData
FileName=Microsoft.Data.Edm, Version=5.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
FusionLog==== Pre-bind state information ===
LOG: User = REDMOND\hongyes
LOG: DisplayName = Microsoft.Data.Edm, Version=5.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///c:/users/hongyes/documents/visual studio 2012/Projects/MvcApplication1/UnitTestProject1/bin/Debug
LOG: Initial PrivatePath = NULL
Calling assembly : System.Web.Http.OData, Version=0.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
LOG: This bind starts in default load context.
LOG: Using application configuration file: c:\users\hongyes\documents\visual studio 2012\Projects\MvcApplication1\UnitTestProject1\bin\Debug\UnitTestProject1.dll.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.Data.Edm, Version=5.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///c:/users/hongyes/documents/visual studio 2012/Projects/MvcApplication1/UnitTestProject1/bin/Debug/Microsoft.Data.Edm.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
StackTrace:
at System.Web.Http.QueryableAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
at System.Web.Http.Filters.ActionFilterAttribute.CallOnActionExecuted(HttpActionContext actionContext, HttpResponseMessage response, Exception exception)
InnerException: