Search code examples
asp.netdb4omedium-trust

db4o running in asp.net Medium Trust environment


I am using the embedded client/server version of db4o (I called OpenServer() instead of OpenFile() method) so that I can host an asp.net website that will have several users reading and writing to the database simultaneously. The only issue is that the webhost that we use is a medium trust environment so it's throwing an error stating that the assembly doesn't support partially trusted callers...

Wondering if anyone has any suggestions on how to get this to work. Thanks!

:: UPDATE ::

I have recompiled the db4o dll with the [AllowPartiallyTrustedCallers] attribute and now I am getting the following specific error:

System.TypeInitializationException was unhandled by user code Message="The type initializer for 'DataObjecten.db4oManager' threw an exception." TypeName="DataObjecten.db4oManager" InnerException: System.Security.SecurityException Message="Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed." Source="Db4objects.Db4o" StackTrace: at Db4objects.Db4o.Internal.Platform4.AddShutDownHook(PartialObjectContainer container) at Db4objects.Db4o.Internal.PartialObjectContainer.Initialize1(IConfiguration config) at Db4objects.Db4o.Internal.PartialObjectContainer.Open() at Db4objects.Db4o.Internal.IoAdaptedObjectContainer..ctor(IConfiguration config, String fileName) at Db4objects.Db4o.Internal.ObjectContainerFactory.OpenObjectContainer(IConfiguration config, String databaseFileName) at Db4objects.Db4o.Db4oFactory.OpenFile(IConfiguration config, String databaseFileName) at Db4objects.Db4o.Db4oFactory.OpenServer(IConfiguration config, String databaseFileName, Int32 port, INativeSocketFactory socketFactory) at Db4objects.Db4o.Db4oFactory.OpenServer(IConfiguration config, String databaseFileName, Int32 port) at DataObjecten.db4oManager..cctor() InnerException:


Solution

  • I have found that db4o will NOT work in a medium trust environment. Anyone who is looking for a nosql solution that is embeddable or server enabled and usable in a medium trust environment should take a look at ravendb.net - solved all of my issues... (must use the munin managed storage engine).

    Similar to an object database (db4o) but without all the headache and much more versatile. Also, works with things like link or standard querying via JSON/HTTP...

    Big perks are:

    Full text searching via Lucene.NET Sharding/ Auto-Sharding Replication (WAN/LAN) LINQ Indexing / Auto Indexing Great performance (way faster than db4o) Native to .NET ACID compliant Transactions Multi-Tenancy Run in Client/Server mode or embedded Capable of running in Medium Trust