0

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:

bbqchickenrobot
  • 3,592
  • 3
  • 45
  • 67
  • Just added an update to my post... still trying to see if I can wrap my head around this one... – bbqchickenrobot Jun 30 '09 at 04:24
  • 1
    Did you ever manage to solve this? I'm considering using db4o too but apprehensive about it if I cant use it in medium trust - not in medium trust ATM but you never know... – Darko Sep 01 '09 at 02:32
  • No, never got it working. I am going to revisit this soon however. Hopefully there will be a solution. – bbqchickenrobot Feb 01 '10 at 18:30

3 Answers3

0

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.

samjudson
  • 56,243
  • 7
  • 59
  • 69
  • Hey Same, thanks for the response - Looking at the source for db4o I found that they are already compiling it with the APTC attribute on the dll's. Hmm... seems to have no effect. Maybe it's due to me using the client/server mode. I will try using the OpenFile() method instead of OpenServer() and see if I get the same security exception. If so, maybe i'll try your wrapper suggestion. – bbqchickenrobot Jun 29 '09 at 17:33
0

I've hit this problem as well and it does appear that db4o will not work in client/server mode in a medium trust web application environment.
This project for ASP.NET Providers using db4o seems to confirm this.
It states that db4o is reliant on reflection and unmanaged code which are both prohibited in medium trust.
I think your only hope to progress this would be to follow their suggestion and find a shared provider that allows you to run your code in full trust.
Very disappointing as I've enjoyed working with db4o and this has just scuppered several weeks of work.

Andy Rose
  • 16,770
  • 7
  • 43
  • 49
  • 1
    Indeed, db4o does depends on reflection (regarding unmanaged code, we used to depend directly on native code but we don't depend anymore). AFAIK (I am not a security expert), the APTC attribute should be enough to allow db4o to be used in medium trusted environments. Anyway, since we still have an open issue (http://tracker.db4o.com/browse/COR-51) related to this subject I'll discuss this in our next meeting. – Vagaus Jun 18 '10 at 10:38
-1

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

bbqchickenrobot
  • 3,592
  • 3
  • 45
  • 67