question

Yisman avatar image
Yisman asked

SMO System.Security.SecurityException

Hello everybody

I wrote a backup procedure using smo. this procedure works great on my dev box, but once deployed to the hosting company's web server it throws above exception ("System.Security.SecurityException: That assembly does not allow partially trusted callers.")

I did some research on the subject and it seems that hosting companies give you only medium trust in the config file and hence cannot access smo.

My hosting admin is a great fellow (www.alsonetworks.com, recommended!) and is willing to help out, so he told me that he:

A. installed smo 2008 in the GAC

B. added them to the medium.config file

Even so, I still receive the error. Now, I'm pretty sure he'd do anything possible to get it to work (sans giving full trust) but i'd got to tell him what to do.

So can anybody advise any additional steps that can be done to get this to work?

my site is built with vb asp.net 3.5 against mssql 2008, but the hosting site uses mssql 2005.

I appreciate your help and advice

PS. I've also read a lot about AllowPartiallyTrustedCallers, but I understand that it is irrelevant here as i have not written the assembly. it would be something ms could/should do. is that correct?

I've already posted this question on other forums but havent got no answer yet. Is there something wrong or terribly simple here? Please advise.

sql-server-2008sql-server-2005backup
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Matt Whitfield avatar image
Matt Whitfield answered

MSDN is reasonably unambiguous on the topic:

Applications that receive less than full trust by the runtime code access security system are not allowed to call shared managed libraries unless the library writer specifically allows them to through the use of the AllowPartiallyTrustedCallersAttribute Class. Therefore, application writers must be aware that some libraries will not be available to them from a partially trusted context.

So, you have two options.

  1. Get Microsoft to change SMO to allow partially trusted callers. You could post a request on Connect, but to be honest you'd probably have more luck trying to invent a chocolate teapot.
  2. Get your system admin to grant full trust to the application.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.