Code Access Security Question

G

Guest

I have a component dll that lives in the GAC. One of the classes in the
component dll calls unmanaged code. I use the component dll from an ASP.NET
application that I'm trying to get to run under medium trust. My call looks
like this:

ASP.NET Application ---> Component in GAC ---> Unmanaged code.

when my component in the GAC calls the unmanaged code, .NET throws a
security exception. I was under the impression that all code in the GAC runs
under full trust? In order to get this to work without changing the ASP.NET
app back to full trust, I have to explicitly Assert the unmanaged code
permission in my component. Is there an implicit LinkDemand requirement on
all calls to unmanaged code or something like that?

Thanks in advance for any help,

Jeff
 
B

Bryan Phillips

The Assert command is what you really needed to do. When you call
Assert, it stops the CLR from walking farther up the call stack looking
at each method and determining permissions. The additional bonus is
that stopping the call stack walk will boost performance.

Though the DLL's in the GAC run under full trust, the call stack was
walked backwards into your ASP.Net code which does not have the correct
permissions to call unmanaged code.

Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top