Doesn't work when Medium Trust

My shared hosting is set to Medium Trust and when I change my trust level of my project to medium trust in the web.config file, even running locally I get the following error:

Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: That assembly does not allow partially trusted callers.