Elias presents ... a worm!    Thoughts on family, philosophy,
and technology


Monday, July 30, 2007

db4o ASP.NET Providers

My open-source project of db4objects-backed Membership, Role, and Profile ASP.NET Providers is up on CodePlex here.


db4objects is an object database that I'm fairly enamored with these days. Whereas with a relational database I'd have to write lots of SQL and plumbing to read and write objects, with db4objects in .NET 2.0 I can store an object by calling Set(object), and load an object by calling the Query<>() method with an anonymous delegate that simply expresses the identity of the target, like this:

IList<EnrolledUser> results =
delegate(EnrolledUser u)
return u.Username == username &&
u.ApplicationName ==

The Achilles' heel (to be dramatic) of db4objects for .NET is that it requires Full Security CAS privileges, since it uses reflection and Win32. That's a problem for hosted web applications which are constrained to the Medium Security model -- which is very common and proper. I've thought 'round and 'round this problem, and there's no readily plausible solution other than finding a host which is willing to run your web app with Full Security -- which is, of course, in general a very bad idea!

The Providers

My project contains implementations for three core ASP.NET providers so far. They are based on MSDN sample code, and they are "well" unit-tested, meaning: I tried to retroactively "drive" most of the behavior with tests, but there are some holes.

There was an older, similar project on SourceForge here, but that one was not based on the MSDN sample code, was not unit-tested, hadn't been touched in 18 months, did not include a Profile provider, and used an older version of db4objects and the older method of querying. So I wrote this one. And let me tell you, it is not easy to unit test a Membership Provider; I never could have done it had I not found an archived post of a blog that doesn't exist anymore which explained how to hack it!

I'm curious myself about what bugs I'll find once I (or others) start using this project more. It's been downloaded more than 40 times already, so I hope -- and fear -- some bug reports sometime soon.



  • At 8:45 PM , Blogger ali said...

    hello there...

    I have downloaded db4oprovider but since I am pretty new to both and db4o, I do not know how to integrate it with

    What exactly I have to do in the web.config to make it work.

    Is there an sample anywhere that i can look at to see how it works. Would really appreciate that!

  • At 1:06 AM , Blogger Brad Williams said...

    Hi Ali, I have emailed you!


Post a Comment

Subscribe to Post Comments [Atom]

<< Home