Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
You're getting «HRESULT: 0x80070005 (E_ACCESSDENIED)» when you try to create subwebs using a custom site definition programmatically?
For a quick work-around, just add this to your Assembly.info.cs file, re-compile and re-deploy:
using System.Security; ... [assembly:AllowPartiallyTrustedCallers]
using System.Security;
...
[assembly:AllowPartiallyTrustedCallers]
Signing and making your code trusted should also work, but if you're on a tight spot, this code will probably get you some air to breath
Hope this helps someone out there