views:

55

answers:

2

I have a relatively simple ASP.net MVC 2 app that is using SubSonic. Everything seems to work well locally, but when I deployed it to WinHost, I keep getting an exception like so:

System.TypeAccessException: Attempt by method 'DynamicClass.lambda_method(System.Runtime.CompilerServices.Closure, System.Data.Common.DbDataReader)' to access type 'System.RuntimeType' failed.
   at lambda_method(Closure , DbDataReader )
   at SubSonic.Linq.Structure.DbQueryProvider.Project[T](DbDataReader reader, Func`2 fnProjector)
   at SubSonic.Linq.Structure.DbQueryProvider.Execute[T](QueryCommand`1 query, Object[] paramValues)
   at lambda_method(Closure )
   at SubSonic.Linq.Structure.DbQueryProvider.Execute(Expression expression)
   at SubSonic.Linq.Structure.QueryProvider.System.Linq.IQueryProvider.Execute[S](Expression expression)
   at System.Linq.Queryable.Count[TSource](IQueryable`1 source)
   at Foo.Web.Data.Baz.SingleOrDefault(Expression`1 expression)
   at Foo.Web.Models.Data.DataFacade.GetBar(Int32 id)
   at Foo.Web.Controllers.Baz.Edit(Int32 id)
   at lambda_method(Closure , ControllerBase , Object[] )

It's definitely a head scratcher as I am not sure what specifically I am doing wrong. My assumption is that its environmental (possibly permissions based). I am not sure if its a LINQ query issue, SubSonic, or something specific to WinHost. Does anyone have an idea on how I should approach this or where/what the issue is? Once more, the app works fine locally.

Note: the object/method names are changed in the sample

A: 

Have you tried changing the trust level of your application?

bleevo
+2  A: 

This looks like a medium trust issue. Current releases of subsonic do not support medium trust. If you pull the latest from github (http://github.com/subsonic/SubSonic-3.0) apprently a change on July 10th enabled medium trust. I have tried it myself but the source is pretty reliable.

stimms
I concur with the answer but ended up resolving the issue by moving to another host. I was never able to pinpoint the exact issue (but I do think medium trust was the root cause).
rifferte