R – db4o running in asp.net Medium Trust environment

asp.netdb4omedium-trust

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:

Best Answer

I don't know if this works, but you could try writing a wrapper DLL that has AllowPartiallyTrustedCaller set to true, and passes all calls to the db4o DLL.

Seeing as db4o is open source you could download and recompile with AllowPartiallyTrustedCaller set to true yourself of course.

This thread however suggests that that might not work.