Don
Don

Reputation:

Running ASP.Net websites in Medium Trust environments

Disclaimer: I have limited ASP.Net skills

I have a couple of websites which I am transferring from my current hosting onto the Mosso hosting service. When I tried transferring one of the websites, I got the error "System.Security.SecurityException: That assembly does not allow partially trusted callers.", which appears to have to do with the fact that Mosso runs on Medium Trust for ASP.Net apps, and the code in the website appears to require full-trust.

Unfortunately, I don't have access to the full source code for the app, and the original developer is not available. Is there any easy workaround to porting these websites? I tried adding in web.config but that didn't work.

I don't think asking Mosso to adjust the security level is an option, because they had refused when I asked them.

Does anybody have any ideas?

Upvotes: 0

Views: 2282

Answers (3)

Micky McQuade
Micky McQuade

Reputation: 1858

I know this is old, but I thought I'd add something to it that might help. Mosso's change to Medium trust caused us some issues as well.

We use BlogEngine.NET and access MySQL for its backend. We had the MySQL dll in our bin directory and that was causing issues with medium trust. Once Mosso added a MySQL dll to the GAC, we were able to use it successfully.

Obviously, I don't know your particular details and what you are trying to do, but if it is related to MySQL, let me know.

Upvotes: 0

Skittles
Skittles

Reputation: 887

Sorry to say but unless they allow you to set the trust level, you could have big issues. You could have a look here. Professional ASP.NET 2.0 Security, Membership, and Role Management

Almost exactly the same thing happened to me, except the my hosting company changed their trust policy after I a number of websites running on their servers for a couple of years. In the end I had to give up and move to DiscountASP as they overrode <trust level="Full" /> in my congfig file.

Here was my original question. ASP.NET WebPermission Security Exception

Good luck

Upvotes: 0

Cerebrus
Cerebrus

Reputation: 25775

Is your assembly strong named? Does it call strong named assemblies?

You should apply the 'AllowPartiallyTrustedCallers` attribute to the Assembly. More information about this attribute is available here.

From the docs:

By default, a strong-named assembly that does not explicitly apply this attribute at assembly level to allow its use by partially trusted code can be called only by other assemblies that are granted full trust by security policy. This restriction is enforced by placing a LinkDemand for FullTrust on every public or protected method on every publicly accessible class in the assembly. Assemblies that are intended to be called by partially trusted code can declare their intent through the use of the AllowPartiallyTrustedCallersAttribute.

See this MSDN article for more information.

Edit:


Some information that confirms my suspicions that the APTCA attribute is a possible solution to the problem:

https://support.isqsolutions.com/article.aspx?id=10334
http://bloggingabout.net/blogs/rick/archive/2006/04/07/11929.aspx

Upvotes: 1

Related Questions