Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does ASP.NET Web API (beta) run with the latest Mono (stable)?

I'm trying to get the new ASP.NET Web API beta (VS 2010 default Web API project) running on Ubuntu 10.04 with Mono 2.10.8.1. Unfortunately I failed miserably in all my attempts so far. The most "meaningful" exception I got is the following:

System.TypeLoadException: Could not load type 'RestTest.Controllers.ValuesController' from assembly 'RestTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
  at (wrapper managed-to-native) System.Type:type_is_assignable_from (System.Type,System.Type)
  at System.Type.IsAssignableFrom (System.Type c) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.AreaRegistration.IsAreaRegistrationType (System.Type type) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.TypeCacheUtil+<>c__DisplayClass1.<FilterTypesInAssemblies>b__0 (System.Type type) [0x00000] in <filename unknown>:0 
  at System.Linq.Enumerable+<CreateWhereIterator>c__Iterator35`1[System.Type].MoveNext () [0x00000] in <filename unknown>:0 
  at System.Collections.Generic.List`1[System.Type].AddEnumerable (IEnumerable`1 enumerable) [0x00000] in <filename unknown>:0 
  at System.Collections.Generic.List`1[System.Type]..ctor (IEnumerable`1 collection) [0x00000] in <filename unknown>:0 
  at System.Linq.Enumerable.ToList[Type] (IEnumerable`1 source) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.TypeCacheUtil.GetFilteredTypesFromAssemblies (System.String cacheName, System.Predicate`1 predicate, IBuildManager buildManager) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.AreaRegistration.RegisterAllAreas (System.Web.Routing.RouteCollection routes, IBuildManager buildManager, System.Object state) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.AreaRegistration.RegisterAllAreas (System.Object state) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.AreaRegistration.RegisterAllAreas () [0x00000] in <filename unknown>:0 
  at RestTest.WebApiApplication.Application_Start () [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 

I don't think there is anything wrong with the actual "ValuesController" class. It's basically an empty class. Instead there seems to be a problem with the base class called "ApiController" which is distributed with the NuGet package "AspNetWebApi.Core.4.0.20126.16343" (System.Web.Http.dll). I check all the new libraries with "MoMA" (Mono Migration Analyzer) and the results are that quite a few methods seem not to be implemented yet.

So my questions are: Does anyone know when the ASP.NET Web API can be used together with Mono? Is there any way to get it running anyway (maybe by using the Microsoft libs instead of Mono)?

Addendum:

Quick note to those trying to run a regular MVC4 project on mono with the above configuration. I ran into slight problems because one method - namely AllowOnlyFipsAlgorithms() - has not been implemented yet. It's called somewhere in "System.Web.Optimization" by "CreateHashAlgorithm" and in order to get my project running I had to remove all references to this library. Yes, you have to do without all the new and neat CSS/Javascript bundling capabilities for now, but at least you get your site up.

like image 676
UnclePaul Avatar asked Mar 10 '12 17:03

UnclePaul


People also ask

Is ASP.NET Core stable?

ASP.NET Core is designed to allow runtime components, APIs, compilers, and languages evolve quickly, while still providing a stable and supported platform to keep apps running. Multiple versions of ASP.NET Core can exist side by side on the same server.


1 Answers

It's possible but could be a pain. Consider servicestack.net that runs both on mono and windows.

like image 86
Rui Marques Avatar answered Oct 04 '22 11:10

Rui Marques