Share via


Using Unity in Partial Trust Environments

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

There are two limitations when using the Unity Application Block in a partial trust environment. Unity uses dynamically generated methods to perform injection, and the .NET security model imposes some security limitations that you should be aware of if you want to use Unity in applications that will run in less than full trust environments. The limitations are the following:

  • You cannot resolve value types. This means that you cannot use the Resolve method of the container to resolve types such as int (C#) or Integer (VB.NET).
  • You cannot register and use mappings using the RegisterType methods where the target class is internal (C#), Friend (VB.NET), private (C#), or Private (VB.NET).

For more information about security issues when using dynamically generated MSIL code, see Security Issues in Reflection Emit for .NET 3.5 and Security Issues in Reflection Emit for .NET 2.0.