App_Data access error, only when specific module is enabled

Topics: General, Installing Orchard, Troubleshooting, Writing modules
Feb 1, 2012 at 8:47 PM

See here for more details: 

I posted there as I originally thought the error might be related to the Combinator module, since the error only happens when that module is enabled. But I'm thinking now that the error could be something in Orchard that the Combinator module is uncovering. 

I'm running an up to date copy of 1.x branch. I did a clean all / rebuild all in VS2010, and copied the Orchard.Web folder to my qa environment web server. Ran my rehydrate script which launches my recipes to set up the modules I use as well as importing some static data. Whenever I enable Piedone.Combinator module I get a .NET "The resource cannot be found" error, and this Exception in the error log:

2012-02-01 18:54:00,172 [5] Orchard.Environment.DefaultOrchardHost - A tenant could not be started: Default
System.UnauthorizedAccessException: Access to the path 'C:\sites\mysite\App_Data\Sites\Default\mappings.bin' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at Orchard.FileSystems.AppData.AppDataFolder.CreateFile(String path) in C:\projects\OrchardEnlistments\1.x\src\Orchard\FileSystems\AppData\AppDataFolder.cs:line 122
   at Orchard.Data.SessionConfigurationCache.StoreConfiguration(ConfigurationCache cache) in C:\projects\OrchardEnlistments\1.x\src\Orchard\Data\SessionConfigurationCache.cs:line 73
   at Orchard.Data.SessionConfigurationCache.GetConfiguration(Func`1 builder) in C:\projects\OrchardEnlistments\1.x\src\Orchard\Data\SessionConfigurationCache.cs:line 57
   at Orchard.Data.SessionFactoryHolder.BuildConfiguration() in C:\projects\OrchardEnlistments\1.x\src\Orchard\Data\SessionFactoryHolder.cs:line 93
   at Orchard.Data.SessionFactoryHolder.GetConfiguration() in C:\projects\OrchardEnlistments\1.x\src\Orchard\Data\SessionFactoryHolder.cs:line 71
   at Orchard.Data.SessionFactoryHolder.GetSessionFactory() in C:\projects\OrchardEnlistments\1.x\src\Orchard\Data\SessionFactoryHolder.cs:line 62
   at Orchard.Data.SessionLocator.For(Type entityType) in C:\projects\OrchardEnlistments\1.x\src\Orchard\Data\SessionLocator.cs:line 29
   at Orchard.Data.Repository`1.get_Table() in C:\projects\OrchardEnlistments\1.x\src\Orchard\Data\Repository.cs:line 30
   at Orchard.Data.Repository`1.Fetch(Expression`1 predicate) in C:\projects\OrchardEnlistments\1.x\src\Orchard\Data\Repository.cs:line 126
   at Orchard.Data.Repository`1.Get(Expression`1 predicate) in C:\projects\OrchardEnlistments\1.x\src\Orchard\Data\Repository.cs:line 91
   at Orchard.Core.Settings.Descriptor.ShellDescriptorManager.GetDescriptorRecord() in C:\projects\OrchardEnlistments\1.x\src\Orchard.Web\Core\Settings\Descriptor\ShellDescriptorManager.cs:line 57
   at Orchard.Core.Settings.Descriptor.ShellDescriptorManager.GetShellDescriptor() in C:\projects\OrchardEnlistments\1.x\src\Orchard.Web\Core\Settings\Descriptor\ShellDescriptorManager.cs:line 31
   at Orchard.Environment.ShellBuilders.ShellContextFactory.CreateShellContext(ShellSettings settings) in C:\projects\OrchardEnlistments\1.x\src\Orchard\Environment\ShellBuilders\ShellContextFactory.cs:line 66

The error happens no  matter how I try to install/enable Combinator. If i remove the references to COmbinator in my recipe my app starts up fine. If I enable it in the recipe I get the error. It doesn't make any difference if I deploy Combinator in the Modules folder when I copy it over from my dev workstation, or if I tell the recipe to grab the module from the Gallery (<Module packageId="Orchard.Module.Piedone.Combinator" />), or if I get the app running and then try to enable it with the command line "feature enable" command. 

I don't have the problem on my local machine, but there I always run my site from VS2010's built in web server. 

I noticed that Combinator uses a feature called "Tasks". Is it possible that this or some other dependency of Combinator is causing the problem? 

Feb 1, 2012 at 9:12 PM
Edited Feb 1, 2012 at 9:14 PM

Following from the other discussion:

Tasks is actually a Helpful Libraries feature and should have nothing to with do that (it's a bug with the 1.1.1 Combinator release that it's listed as a dependency; it's not one and nothing is used from it).

Since your permissions are set up correctly and other modules work, I'm out of ideas. Just for clarification: as this looks like a problem with record mappings, there are two point where Combinator uses the database: it uses an IRepository<CombinedFileRecord> instance directly and a part attached to site settings. Now this is nothing special, but maybe, maybe the problem lies in the direct usage of IRepository. This is just a wild idea: modules tend not to use IRepository directly, so this could be a point where Combinator is unique among your installed modules (but e.g. Tags also does that: if you can add tags without problem then there's something else).

Also Combinator uses IStorageProvider for file system access (this regarding your thought about file locking), but this should have little to do with mappings.bin and the App_Data folder.

Feb 1, 2012 at 11:19 PM
Edited Feb 1, 2012 at 11:32 PM

OK, I was mistaken. It was a permissions issue. Every reference to granting permissions I've read has mentioned granting permissions for "IIS AppPool\DefaultAppPool", so that's what I granted permissions to. Turns out that you are supposed to replace "DefaultAppPool" part with the name of the app pool. "DefaultAppPool" will work if you are in fact using the default app pool for your site. 

I have a habit of creating one pool per site, and naming the pools after the site. So I have an IIS app named, and a corresponding app pool named 

I fixed the problem by granting permissions to the "IIS AppPool\" identity like so:


 ICACLS App_Data /grant "IIS AppPool\":F /T


Thanks for your help, piedone. BTW, still loving your Combinator module! I noticed you added the "sets" feature we discussed, and you also fixed the cache busting. I'll try the new code out soon. 

Feb 1, 2012 at 11:28 PM

Glad to hear that! I'll release the new version with sets soon or you're welcome to try the code from the repository, it's stable, but update Helpful Libraries first.

Feb 2, 2012 at 1:08 AM

What references did you read about granting permissions? If it's in any Orchard docs they need updating, app pools are there for a reason and DefaultAppPool certainly shouldn't be considered the common case.

Feb 2, 2012 at 4:32 AM

Nothing Orchard specific. Google for "set permissions for ApplicationPoolIdentity" or something like that and a lot of the results don't make it that clear that the app pool name makes up part of the account name. Once I looked closer I found that the 1st resullt (a serverfault question) had the info mentioned at the very end of the accepted answer. I didn't catch that till after i visited the link a 2nd time.