I have been fighting with a permissions issue with SharePoint today. What’s been happening is that I have a custom dll that I created which will load just fine if I don’t really have it do anything. However, once it starts running code that accesses the SharePoint Object model, then I get the SharePoint.Security error. This is essentially a permissions denied error.
I found this blog post that I think will be very helpful. I will try his suggestion and provide than update shortly.