As of the ES 2007 v0.0415 version Medium Trust is supported. There are a few tips we'd like to share with you to help you get up and running in Medium Trust mode for ASP.NET.
Medium Trust doesn't allow custom configuration sections. This means you need to use the EntitySpaces configless support, here is an example from our global.asax file. If your project doesn't have a global.asax just use Visual Studio to add a "Global Application Class".
Code:
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
//---------------------------------------------------------------
// --- Manually register a connection (DO THIS ONE TIME ONLY) ---
//---------------------------------------------------------------
EntitySpaces.Interfaces.esConnectionElement conn =
new EntitySpaces.Interfaces.esConnectionElement();
conn.ConnectionString = @"User ID=sa;Password=;Initial Catalog=Northwind;Data Source=localhost;";
conn.Name = "Sql";
conn.Provider = "EntitySpaces.SqlClientProvider";
conn.ProviderClass = "DataProvider";
conn.SqlAccessType = EntitySpaces.Interfaces.esSqlAccessType.DynamicSQL;
conn.ProviderMetadataKey = "esDefault";
conn.DatabaseVersion = "2005";
// --- Assign the Default Connection ---
EntitySpaces.Interfaces.esConfigSettings.ConnectionInfo.Connections.Add(conn);
EntitySpaces.Interfaces.esConfigSettings.ConnectionInfo.Default = "Sql";
//---------------------------------------------------------------
// Assign the Medium Trust Loader
//---------------------------------------------------------------
EntitySpaces.Interfaces.esProviderFactory.Factory =
new EntitySpaces.LoaderMT.esDataProviderFactory();
}
</script>
We are going to change this so you can pull the connection string from the web.config file using the standard <connectionStrings> section before the final release of ES 2007 but this will be a very minor change.
Instead of
Code:
conn.ConnectionString = @"User ID=sa;Password=;Initial Catalog=Northwind;Data Source=localhost;";
You will do this:
Code:
conn.ConnectionString ="std:MyConnectionString";
And this will pull the actual connection string from the standard .NET <connectionStrings> area, in this case the one named MyConnectionString.
Also, some data bindings that work just fine are
Code:
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
And
Code:
<asp:TemplateField HeaderText="BirthDate" SortExpression="BirthDate">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# String.Format("{0:MM/dd/yyyy}",
(DateTime?)((BusinessObjects.Employees)Container.DataItem).BirthDate)%> '></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<%# String.Format("{0:MM/dd/yyyy}", (DateTime?)((BusinessObjects.Employees)Container.DataItem).BirthDate)%>
</ItemTemplate>
</asp:TemplateField>
Our esDataSource runs just fine under Medium Trust as well.
- Special Thanx goes to Jeff Kirby for working through the issues with us. Thanks Jeff.