Search code examples
c#linqreflectiontrust

LINQ reflection with Host Level Trust


I'm having difficulty with my project and deploying it on my web hosting provider. I'm on a shared hosting environment with "Host Level" trust.

I have used LINQ in my project but now they've just told me that Reflection is disabled on their shared services. I believe that reflection is required to be able to use variables within the queries.

When I run the project in the host level trust environment, I get an Exception:

MethodAccessException:
System.Runtime.CompilerServices.StrongBox`1..ctor(System.__Canon)

Does anyone have any experience in this area? Any suggestions would be greatly appreciated

It's failing on this code:

public override bool ValidateUser(string username, string password) {

   using (var dc = new mcDataContext()) {
      var query = (from c in dc.CF_Clients
                   where c.Client_ID == username
                   select new
                   {
                      c.Client_Password
                   }).FirstOrDefault();

  }
}

Solution

  • Is everything in the query a public member in a public class?

    See http://social.msdn.microsoft.com/forums/en-US/adodotnetdataservices/thread/0dc87db4-c145-456b-a19f-eebc16c09efb/

    Another possible solution:

    http://www.nullify.net/Article/332.aspx