ravendbembedded-databasemedium-trust

RavenDB EmbeddedDocumentStorage in Medium Trust


I'm trying to use RavenDB in Medium Trust, I would like to try the embedded model, since the hosting (cheap) I use will not allow to install a service. My code to initialize is the following:

private void ConfigureStorage()
    {
        store = new EmbeddableDocumentStore();
        store.Configuration.DefaultStorageTypeName = "munin";
        store.Configuration.DataDirectory=Server.MapPath("$/App_Data");
        store.Initialize();
    }

that works in full trust, but in Medium it throws:

Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. with the following stack trace:

[SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
   System.StubHelpers.StubHelpers.DemandPermission(IntPtr pNMD) +0
   Microsoft.VisualBasic.CompilerServices.NativeMethods.GlobalMemoryStatusEx(MEMORYSTATUSEX& lpBuffer) +0
   Microsoft.VisualBasic.Devices.InternalMemoryStatus.Refresh() +68
   Microsoft.VisualBasic.Devices.InternalMemoryStatus.get_TotalPhysicalMemory() +11
   Microsoft.VisualBasic.Devices.ComputerInfo.get_TotalPhysicalMemory() +49
   Raven.Database.Config.InMemoryRavenConfiguration.GetDefaultMemoryCacheLimitMegabytes() +301
   Raven.Database.Config.InMemoryRavenConfiguration.Initialize() +631
   Raven.Database.Config.RavenConfiguration.LoadConfigurationAndInitialize(IEnumerable`1 values) +311
   Raven.Database.Config.RavenConfiguration..ctor() +189
   Raven.Client.Embedded.EmbeddableDocumentStore.get_Configuration() +99
   Wine2.MvcApplication.ConfigureStorage() +84
   Wine2.MvcApplication.Application_Start() +84

Raven build is: Version 573

Are there some workaraound to make it working under medium trust, or is this scenario unsupported?


Solution

  • Under strict medium trust, RavenDB won't work. But there plenty of hosting companies that provide hosting where RavenDB does work, because they tweaked the permissions.