Got code to compile but getting error about DataController

Topics: ASP.NET MVC, ASP.NET Single Page Application, ASP.NET Web API, General
Apr 9, 2012 at 7:27 PM

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0012: The type 'System.Web.Http.Data.DataController' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.Http.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.


So I got the latest source for mvc.net because I can't use the current mvc.net 4.0 web api code to work with Entity Framework 5.0 beta 2 properly.  I removed all of the signed stuff and built the dlls which worked fine as far as that went except there are now several missing dlls that appear to be in the Microsoft.Web.Http.Data.EntityFramework etc. dlls. So I added those to my project as well.

---

I get the above error on execute of any mvc.net page.  If I go directly to the web api method I get the following:

Could not load type 'System.Net.Http.HttpMessageInvoker' from assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

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.TypeLoadException: Could not load type 'System.Net.Http.HttpMessageInvoker' from assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

----

Anyone have suggestions on how to get this stuff to build properly?

 

Apr 9, 2012 at 7:39 PM

Sorry you're running into issues. Do you have .NET 4.5 Beta installed on your machine? If so, the WebAPI sources you build yourself will unfortunately not be able to run on that machine. The current sources checked into master require a newer version of System.Net.Http.dll than the one installed on your system with .NET 4.5 Beta. To run the latests compiled bits you will have to either uninstall .NET 4.5 Beta or wait until a compatible version of .NET 4.5 becomes available.

Apr 9, 2012 at 7:41 PM

Argh.

I need .net 4.5 because of using Entity Framework 5.0 and Enums and spatial...

Any ETA on when the next build is going to be?

Apr 9, 2012 at 7:47 PM

Sorry, but that schedule is determined outside of our team so we have no info we can share publically. Hopefully soon.

Apr 9, 2012 at 7:51 PM

Any way to get into internal test builds?

We're building beta code for a project that is going to take months and right now we're on a serious road block. We're building a HUGE application and would be able to provide excellent feedback.

Apr 9, 2012 at 8:04 PM

Or alternatively, is there a work around for this error with EF 5.0 Beta 2:

 

<Message>
Could not load type 'System.ComponentModel.DataAnnotations.DatabaseGeneratedAttribute' from assembly 'EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
</Message>
<StackTrace>
at System.Web.Http.Data.EntityFramework.Metadata.LinqToEntitiesTypeDescriptor.GetMemberAttributes(PropertyDescriptor pd) at System.Web.Http.Data.EntityFramework.Metadata.TypeDescriptorBase.GetProperties() at System.Web.Http.Data.Metadata.DataControllerTypeDescriptionProvider.GetForeignKeyMembers() at System.Web.Http.Data.Metadata.DataControllerTypeDescriptionProvider.GetTypeDescriptor(Type objectType, Object instance) at System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetProperties() at System.ComponentModel.TypeDescriptor.GetProperties(Type componentType) at System.Web.Http.Data.DataControllerDescription.AddEntityType(Type entityType, HashSet`1 entityTypes, MetadataProvider metadataProvider) at System.Web.Http.Data.DataControllerDescription.CreateDescription(HttpControllerDescriptor controllerDescriptor) at System.Web.Http.Data.DataControllerDescription.<>c__DisplayClass1.<GetDescription>b__0(Type type) at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) at System.Web.Http.Data.DataControllerDescription.GetDescription(HttpControllerDescriptor controllerDescriptor) at System.Web.Http.Data.DataController.Initialize(HttpControllerContext controllerContext) at System.Web.Http.Data.EntityFramework.DbDataController`1.Initialize(HttpControllerContext controllerContext) at System.Web.Http.ApiController.ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken) at System.Web.Http.Data.DataController.ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken) at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsyncInternal(HttpRequestMessage request, CancellationToken cancellationToken) at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
</StackTrace>

When calling an IQueryable Web API call in the beta?

Apr 9, 2012 at 9:55 PM
Edited Apr 9, 2012 at 10:02 PM
Geminiman wrote:

Any way to get into internal test builds?

We're building beta code for a project that is going to take months and right now we're on a serious road block. We're building a HUGE application and would be able to provide excellent feedback.


If you do not see the source checked into Codeplex to enable support for EF 5.0, you should assume that no such code exists.

EDIT: Sorry, I confused the most recent question with the original answer. Two pieces here. First is the 4.5 problem. The second is EF 5. Even if you were to get a version of .NET 4.5 which works with the current code, the DataController does not support EF 5.0 yet so it wouldn't do you any good.

Apr 9, 2012 at 9:57 PM

If you look at the checkins it's fixed. If you look at connect it's fixed.

However they're all built against ef 4.3 it appears instead of ef 5. Hence I'm going around in circles trying to make this work.

Apr 9, 2012 at 10:08 PM

I edited my original post right after I submitted it because I realized that I misinterpreted the question.

Apr 9, 2012 at 10:27 PM

Argh. Cause EF 4.3 doesn't work with .NET 4.5 worth crap and the link for the work around doesn't work (dead page not found) so it appears that Web API was broken out of the box if you planned on using it with VS.net 2012 and the latest framework... grrreeeeaaaatttt.

Apr 9, 2012 at 10:45 PM
Geminiman wrote:

Argh. Cause EF 4.3 doesn't work with .NET 4.5 worth crap and the link for the work around doesn't work (dead page not found) so it appears that Web API was broken out of the box if you planned on using it with VS.net 2012 and the latest framework... grrreeeeaaaatttt.

Careful not to mix up your definitions, DataController is not part of Web API, it is part of Single Page Application.

Apr 9, 2012 at 10:57 PM

Which relies upon Web API... and is broken with EF 5.0 which is the only version of EF that works properly with VS.net 2012 and .net 4.5

So you can't actually build a SPA as it stands right now using the latest tooling and apis.

Apr 9, 2012 at 11:09 PM

Correct, but the difference in definitions is important, Web API is part of MVC4 so I expect it to be at a much higher quality bar then SPA is.

Apr 10, 2012 at 1:10 PM

Colin: I just looked in the mvc.net code and it appears that SPA is part of it. So I don't see the distinction. But either way this is a pretty major block to adoption.

Apr 10, 2012 at 3:19 PM

Read http://aspnet.codeplex.com/wikipage?title=ASP.NET%20MVC%204%20RoadMap, especially the part about SPA being an early preview that will not be releases as part of MVC 4.

Apr 10, 2012 at 3:34 PM

Colin is correct. SPA will not be part of the final MVC 4 release.

Apr 14, 2012 at 1:49 PM

FYI, I cannot even get this to compile without throwing this error on a fully patched .NET 4.0 only machine.

 

I get exactly the same error as above.

 

Given that it *appears* to be trivial to add $select to the source I WAS going to do a fork and put it in, but until I can debug properly I'm hosed.

Apr 14, 2012 at 2:59 PM
Edited Apr 14, 2012 at 3:03 PM

Request for MS: Make everything in System.Web.Http.Query public. If you really think that $select isn't needed, fine, but make those classes public so that we can inherit and override and fix this stuff without having to fork the code and get into your plumbing.

As far as I can tell there is no reason to have these marked as internal at all. And if they weren't then creating your own attribute would be trivial.

Apr 15, 2012 at 9:11 PM
"Make everything in System.Web.Http.Query public."

Please open an issue in the issue tracker. Thanks!
Apr 17, 2012 at 12:38 AM

Done.