Forum:  Generated code FAQ

Thread:  Can I use the generated code in a Medium Trust environment?


Otis (LLBLGen Pro Team)   Posted on: 05-Apr-2011 11:28:45.
Starting with the LLBLGen Pro runtime framework build of April 4th, 2011, the generated code of v3.0 and v3.1 can be used in a Medium Trust environment. Medium Trust is sometimes required on shared hosting platforms and cloud service providers like GoDaddy or Rackspace.

.NET 4
For using the generated code in a Medium Trust environment with .NET 4, the following additional action has to be taken to avoid a security exception related to inheritance:

Adapter
Add the following line to the AssemblyInfo.cs/vb class in the generated DbGeneric VS.NET project:

Code:

// C#:
[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]

' VB.NET:
<Assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)>


SelfServicing
Add the following line to the AssemblyInfo.cs/vb class in the generated VS.NET project:

Code:

// C#:
[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]

' VB.NET:
<Assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)>


Linq
To use Linq, the service provider has to have enabled ReflectionPermission to be unrestricted. This is in general the case, as Entity Framework and Linq to Sql require this setting to be unrestricted. It's a change in the Medium Trust level, so it's not enabled by default when the default Medium Trust is selected. If your service provider doesn't want to enable ReflectionPermission to be unrestricted, you have to use our native query API instead of Linq. Linq uses compiled lambda's and this .NET 3.5 feature requires ReflectionPermission to be unrestricted.