Internal server Error 500 MVC 4 Web API

lubushyn's Avatar

lubushyn

10 Jun, 2012 09:48 AM

Hi. I deploy MVC 4 Web API project to AppHarbor. Project using .NET Framework 4.0. Project work correct locally. Build from Harbor work correct locally too. But I have Internal server error http://mobilevizorapi.apphb.com/api/Platforms.

  1. Support Staff 2 Posted by rune on 10 Jun, 2012 06:57 PM

    rune's Avatar

    Hi,

    I've inserted the exception I'm seeing below - you might need to bin-deploy another MVC4 assembly?

    Best,
    Rune


    System.TypeLoadException

    Could not load type 'System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption' from assembly 'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.


    Server stack trace: at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes) at System.Reflection.RuntimeAssembly.GetExportedTypes() at System.Web.Http.Dispatcher.DefaultHttpControllerTypeResolver.GetControllerTypes(IAssembliesResolver assembliesResolver) at System.Web.Http.WebHost.WebHostHttpControllerTypeResolver.GetControllerTypes(IAssembliesResolver assembliesResolver) at System.Web.Http.Dispatcher.HttpControllerTypeCache.InitializeCache() at System.Lazy1.CreateValue() Exception rethrown at [0]: at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes) at System.Reflection.RuntimeAssembly.GetExportedTypes() at System.Web.Http.Dispatcher.DefaultHttpControllerTypeResolver.GetControllerTypes(IAssembliesResolver assembliesResolver) at System.Web.Http.WebHost.WebHostHttpControllerTypeResolver.GetControllerTypes(IAssembliesResolver assembliesResolver) at System.Web.Http.Dispatcher.HttpControllerTypeCache.InitializeCache() at System.Lazy1.CreateValue() at System.Lazy1.LazyInitValue() at System.Lazy1.get_Value() at System.Web.Http.Dispatcher.HttpControllerTypeCache.get_Cache() at System.Web.Http.Dispatcher.DefaultHttpControllerSelector.InitializeControllerInfoCache() at System.Lazy1.CreateValue() Exception rethrown at [1]: at System.Lazy1.get_Value() at System.Web.Http.Dispatcher.DefaultHttpControllerSelector.SelectController(HttpRequestMessage request) at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsyncInternal(HttpRequestMessage request, CancellationToken cancellationToken) at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)

  2. rune closed this discussion on 10 Jun, 2012 06:57 PM.

  3. lubushyn re-opened this discussion on 10 Jun, 2012 07:08 PM

  4. 3 Posted by lubushyn on 10 Jun, 2012 07:08 PM

    lubushyn's Avatar

    A am adding this assembly System.ComponentModel.DataAnnotations to build but it's can't halp to me.

  5. Support Staff 4 Posted by rune on 10 Jun, 2012 07:17 PM

    rune's Avatar

    Hmm can you possibly try and uninstall MVC4 from your local machine? Then you'll be able to see if any of those assemblies are missing anyways.

    I'm wondering if what you're trying to use may be contained in a different assembly.

    Best,
    Rune

  6. Support Staff 5 Posted by rune on 10 Jun, 2012 07:18 PM

    rune's Avatar

    Just wanted to add that we'll of course install MVC4 when it becomes RTM.

    Best,
    Rune

  7. 6 Posted by lubushyn on 10 Jun, 2012 07:34 PM

    lubushyn's Avatar

    I've delete reference to 'System.ComponentModel.DataAnnotations assembly, but error happaning. How I can view logs with problem?

  8. Support Staff 7 Posted by rune on 10 Jun, 2012 10:15 PM

    rune's Avatar

    Usually you can set customErrors to "off" and set the element's "errorMode" to "detailed". However that doesn't seem to work in this case, which is likely because this errors happens in WCF. Are the errors not being surfaced if you click the "errors" link on your application page?

    Another option might be to play with the existingResponse attribute of the <httpErrors> element.

    Best,
    Rune

  9. rune closed this discussion on 10 Jun, 2012 10:15 PM.

  10. lubushyn re-opened this discussion on 11 Jun, 2012 05:01 AM

  11. 8 Posted by lubushyn on 11 Jun, 2012 05:01 AM

    lubushyn's Avatar

    Errors page on AppHarbor is clear. I think Web API based on ASP .NET MVC infrastructure (without
    WCF). Actually we have another ability create Rest service based on WCF (I mean WCF Web HTTP approach).

  12. Support Staff 9 Posted by friism on 11 Jun, 2012 09:52 AM

    friism's Avatar

    Hi there, I think System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption is from .NET 4.5 beta which is not currently installed on AppHarbor application servers.

    Let us know if that doesn't help you get your code working.
    Michael

  13. 10 Posted by lubushyn on 11 Jun, 2012 10:33 AM

    lubushyn's Avatar

    Thank you. I know that. But my code not using this now (System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption). Reference to assembly was removed.

  14. Support Staff 11 Posted by friism on 11 Jun, 2012 10:46 AM

    friism's Avatar

    Sorry, I had missed that. Your site seems to be up now though (http://mobilevizorapi.apphb.com/), what's the current problem?

  15. 12 Posted by lubushyn on 11 Jun, 2012 11:11 AM

    lubushyn's Avatar

    The current problem is http://mobilevizorapi.apphb.com/api/Platforms return Internal server error (500), without explanation

  16. Support Staff 13 Posted by friism on 11 Jun, 2012 11:40 AM

    friism's Avatar

    I think your app is still generating the same error. While you may have removed the reference from you project file, you code might still be relying on a gac'ed assembly when running locally. Here's an article on how to get Web API to show errors to remote clients: http://lostechies.com/jimmybogard/2012/04/18/custom-errors-and-erro...

    Let us know if that doesn't help you get your code working.
    Michael

  17. 14 Posted by Pav on 13 Jun, 2012 09:57 PM

    Pav's Avatar

    you can place this in your Application_Start() method inside of global.asax.

    GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

  18. 15 Posted by Pav on 14 Jun, 2012 12:45 AM

    Pav's Avatar

    I found a solution to this problem. Though I don't know if it will work for you. I had to roll my app back to .NET 4 from 4.5. Doing this does not roll back the Entity framework. So just go into nuget, uninstall Entity 5.0.0 PreRelease and reinstall 4.3.1. It worked for me. Also the above code will show you verbose exception to 500 errors on your server.

  19. 16 Posted by lubushyn on 14 Jun, 2012 05:04 AM

    lubushyn's Avatar

    Thanks guys. But after downgrade EF to 4.3.1 I had error. Invalid column name 'CreatedOn'. Actually I do not have 'CreatedOn' in my domain model.

  20. Support Staff 17 Posted by friism on 14 Jun, 2012 11:41 AM

    friism's Avatar

    I haven't attempted this procedure myself, but you may have to sync your database schema with your model after downgrading, in case the two Entity Framework versions have different conventions for generating columns. Since this is not an AppHarbor-related issue, you might also want to pose this question on a site like StackOverflow: http://stackoverflow.com/

    Michael

  21. 18 Posted by Pav on 14 Jun, 2012 06:33 PM

    Pav's Avatar

    Are you using code-first database generation? if so you may have to use migrations to make sure everything is still good with the DB. In my case I used to database first. So when I downgraded, it just regenerated my models from the db.

  22. 19 Posted by lubushyn on 14 Jun, 2012 06:56 PM

    lubushyn's Avatar

    Thaks for all. I am fix all issues and project work fine.

  23. friism closed this discussion on 14 Jun, 2012 07:16 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac