Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Deployment Considerations

This section describes two primary considerations for deploying SQL Server Compact applications:

Besides these topics, if you are upgrading an existing SQL Server database, see Upgrading from Earlier Versions (SQL Server Compact).

Important note Important

SQL Server Compact 4.0 is optimized for use with ASP.NET Web applications, and provides an easy and simple to use database for starter websites.

SQL Server Compact 4.0 is optimized for use as a database for ASP.NET web applications. Web applications are required to run in Medium Trust or Partial Trust, SQL Server Compact 4.0 can also run in medium or partial trust level.

There are two ways in which the SQL Server Compact 4.0 can be used in ASP.NET Web applications:

  • Private Deployment

  • Central Deployment

For more details, see Private Deployment vs. Central Deployment (SQL Server Compact)

ASP.NET maintains the permission set granted to applications with different trust levels in different configuration (.config) files. You need to change the .config file for the medium trust to provide SQL Server Compact 4.0 the proper permissions to run in partial or medium trust.

  • For .NET Framework 4, permissions are configured automatically during installation so no extra configuration is required.

  • Follow these steps for .NET Framework 3.5 SP1:

    1. Add the registry permission class to SecurityClasses Section in Web_MediumTrust.config file.

      <SecurityClasses>
      <SecurityClass Name="ReflectionPermission" Description="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
      <SecurityClass Name="RegistryPermission" Description="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
      </SecurityClasses>
      
    2. Create a new permission set in Web_MediumTrust.config file with the required permissions.

      <PermissionSet class="NamedPermission" version="1" Name="SqlCe_Trust">
          <IPermission class="SecurityPermission" version="1" Flags="UnmanagedCode, SkipVerification"/>
          <IPermission class="EnvironmentPermission" version="1" Read="PROCESSOR_ARCHITECTURE"/>
          <IPermission class ="RegistryPermission" version="1" Read="HKEY_LOCAL_MACHINE\" />
        </PermissionSet>
      
      
    3. Apply the permission set to SQL Server Compact dlls by putting the following lines in Web_MediumTrust.config file.

      CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="ASP.Net">
        <IMembershipCondition class="UrlMembershipCondition" version="1" Url="$AppDirUrl$/*"/>
      
      Append the below code after the lines mentioned above in the (.config) file.
      <CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="SqlCe_Trust" 
          Name="SqlCe_Strong_Name"  Description="This code group grants code signed with the SQLCE strong   name SqlCe_Trust. ">
         <IMembershipCondition class="StrongNameMembershipCondition" version="1"  
       PublicKeyBlob=" 0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8
      "/>
       </CodeGroup>
      

Other Resources

How to: Create an ASP.NET Web Application using SQL Server Compact
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.