This error is an issue that is often encounted, especially in shared hosting, and is due to a higher trust level in place on the shared hosting server in order to provide the best security to all the clients on the server.  In ASP.Net, a trust level defines what level of access your code has to the server.  Higher trust levels have more access to the server, while lower trust levels have less access providing more security between the separate applications. 

Often the application that was created and worked properly on your local development machine doesn't work when you upload it to the shared hosting server and will throw this error.  This is because most local development machine run in Full Trust allowing your ASP.Net application unrestricted access to the machine.  It can do read files and folders outside of its own root, access the registry, and even write to the Windows event log.

For obviously reasons a quality host will take steps to improve the security and stability of its shared servers and limit the access of each individual site.  It is fairly standard practice for shared hosting ASP.Net sites to be required to run under medium trust.  This does occasionally create some issues with executing certain code on the server but almost always there is a different way to accomplish the same task within the constraints of medium trust.

Here is a link with more information on the restrictions of medium trust and also how to configure a server for medium trust that should make it easy for you to setup a development environment that will match the medium trust environment of a shared host.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/PAGHT000020.asp