How to call strong-named assemblies from medium trust code

I'm trying to access a strong-named assembly (NLog) from my asp application but get the security exception (System.Security.SecurityException: That assembly does not allow partially trusted callers.)

This is because the trust level is set to medium on Jodo's web server (which is normal for hosted servers) and strong-named assemblies only allow calls from fully trusted assemblies, as I understand it.

As the assembly I want to use is a 3rd party one, I can't set the AllowPartiallyTrustedCallersAttribute attribute which would solve the problem.


According to this article:
Wiki on technologies | Tutorials / How to call strong-named assemblies from medium trust code

it is possible to get create a wrapper the is strong-named and has the AllowPartiallyTrustedCallersAttribute attribute set. The wrapper would then call the 3rd party assembly. This does not seem to work as I get the same security exception from inside the wrapper.

Any ideas, anyone?
 
I don't have any bright ideas except did you try doing the thing with ILMerge described in the "Further reading" link?

At least now I know why some things insist on full trust when it doesn't seem necessary. A few days ago I tried using the Report Viewer control on Jodo for a local report (ie no SQL Reports server needed). I don't have an immediate use for it but it sure would be useful for a future project. No luck because it needs full trust. :( All it does is read data from a DataSet or other objects and generate HTML. That article explains why. Because it can be put in the GAC (and usually is) it is strongly signed so therefore needs full trust.

Cheers
Ross
 
Ok thanks. The ILMerge trick actually works but it seems a bit ugly. ?( Is this really how Microsoft intended it to work? What's the best practice?

Cheers
Bjorn
 
Back
Top