views:

27

answers:

2

Hi,

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();

  }
}
A: 

Try replacing

from c in dc.CF_Clients

with

from Client c in dc.CF_Clients

Or whatever your type is (in this case I assumed it is a Client object). If you implicitly cast the objects from the collection, then it shouldn't have to use reflection to access the properties in the query.

highphilosopher
This didn't have any effect. I still get the same message on the same piece of code
Mike
Taking out the username variable in my query, and replacing it with String.Empty, and the code works.
Mike
A: 

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

TrueWill
Yes, everything is public, and it still does the same thing
Mike
It's clear others have encountered this. I added a link to a blog post that has a different solution. Not sure if you'll have rights to do that, though.
TrueWill