Sharing a Library with Partially Trusted Code
Several steps must be completed before shared libraries can be called by partially trusted code. For an overview of this issue, see Using Libraries from Partially Trusted Code. You can enable partially trusted access to your libraries by completing the three following tasks:
Strong Name the Assembly
Before your library can be shared through the global assembly cache or used as a downloaded component, you must create a strong name. Complete the following tasks described in Creating and Using Strong-Named Assemblies to strong name your library:
Create a key pair.
Use the Assembly Linker (Al.exe) or an assembly attribute to apply the key pair to your library.
Disable the LinkDemand
The following code example demonstrates how to apply the AllowPartiallyTrustedCallersAttribute attribute to a shared library.
When this attribute is present, all other security checks in your code still work as before, including any class-level or method-level declarative security attributes that are present. This attribute blocks only the implicit LinkDemand enforcement.
Share the Library
After the previous tasks are completed, you can share the library by placing it in the global assembly cache. For more information, see Installing an Assembly into the Global Assembly Cache.
If you want partially trusted callers to be able to call select classes or members in your library, you can place demands on those classes or members. For more information, see.