Orchard 'Error loading assembly' issue

Topics: Troubleshooting
Oct 19, 2015 at 6:21 PM
I have a custom module enabled in our Orchard 1.6.1 site and I am getting the following error after deploying the site to our test environment
Error loading assembly 'Test.MyCustomModule'

System.IO.FileNotFoundException: Could not load file or assembly 'Test.MyCustomModule' or one of its dependencies. The system cannot find the file specified.

File name: 'Test.MyCustomModule'
I have found one "fix" for this, recycling the app pool works but only after attempting to load the site first and seeing it error. Although this works, we don't want to introduce such a manual process to our release procedure and would really like to get to the bottom of the issue.

I have tried the following to no avail:
  • Deleting the contents of the Dependencies folder before releasing to our test environment.
  • Doing an app pool recycle/app pool reset/IIS reset immediately after the release but before loading the site.
  • Used Process Monitor and Fusion Log to try and find the assembly it is failing to load. Process Monitor reported various errors loading DLLs but for each error there was also a success straight after it.
  • Googled around for other people with this error however the resolutions are specific to their particular assembly.
  • Looked at the dependencies.xml file to see which assemblies Orchard is loading and their dependencies. One thing I did notice here is that we reference SquishIt.Framework.dll in our custom module and this does not show up as a dependency of our custom module. However even after the app pool recycle it is still not referenced but the site works.
  • Removed any references added to our module recently. We never used to get this error which suggests a recent change has caused it, however removing any recently added references and related code did not fix the issue.
  • Monitored any file add, edits and deletes after the app pool recycle is performed and the site starts to work. Only the mappings.bin file is changed, it grows from 339 KB to 464 KB. I tried overwriting mappings.bin with the working 464 KB file after the release but upon loading the site this is replaced with the 339 KB file and the site doesn't load.
I'm not sure how to take this further, can anybody point me in the right direction to nail down what the issue is or suggest some potential fixes?
Oct 28, 2015 at 9:53 AM
Not sure if this is related, but have you disabled Dynamic Compilation (see Config/HostComponents.config)?
Unrelated to the assembly load error, but the mappings.bin file is regenerated during application startup. The only time you should need to delete this is when you make a manual schema change to your DB.
Oct 28, 2015 at 9:54 AM
Another thing to check: do you see the Test.MyCustomModule.dll file in the Dependencies folder of App_Data? Does App_Data have write permissions?
Oct 29, 2015 at 1:13 PM
We do have Dynamic Compilation disabled yes, however I've just tried enabling it but the error still occurred.
I to thought the mappings.bin file had nothing to do with it but I thought I'd mention it as it's the only file that changes after the app pool recycle.
The Test.MyCustomModule.dll file is in the Dependencies folder and the folder has write permissions. We clear out this folder during our deployment and it is populated with all the dlls as the site is 'warming up' before the error occurs.
Dec 2, 2015 at 7:19 AM
Edited Dec 2, 2015 at 7:20 AM
We are having the same issue with one of our modules in version 1.9.2

In our case, we have this issue in debug mode with dynamic compilation on. Our module's dll get copied into the dependencies folder, but we get a FileNotFoundException on application startup. After recycling the application pool, it works fine. Probably because the dll is already in the dependencies folder and doesn't need to be copied again.

Things I have tried to resolve this:
  • clean solution, cache, temp files, ...
  • change references
  • set log4net logging to lowest level to get details startup logs. The error originates from this piece of code:
ExtensionEntry extensionEntry;
            try {
                extensionEntry = _cacheManager.Get(extensionId, true, ctx => {
                    var entry = BuildEntry(extensionDescriptor);
                    if (entry != null) {
                        ctx.Monitor(_asyncTokenProvider.GetToken(monitor => {
                            foreach (var loader in _loaders) {
                                loader.Monitor(entry.Descriptor, token => monitor(token));
                    return entry;
            catch (Exception ex) {
                if (ex.IsFatal()) {
                Logger.Error(ex, "Error loading extension '{0}'", extensionId);
                throw new OrchardException(T("Error while loading extension '{0}'.", extensionId), ex);
Have you been able to resolve this issue somehow?
Dec 2, 2015 at 7:44 PM
Does your modules use any of the new C# language features, such as property expressions? Dynamic compilation doesn't seem to support that yet.
Dec 3, 2015 at 7:16 AM
No, we are not using any special C# features.
Dec 3, 2015 at 10:05 AM
We never managed to resolve the issue no.

However we have found that we don't experience the issue in all our environments. On developer's local machines and in our live environment we don't get the issue, however in our internal test and client test environments we do get the issue.

This would suggest a issue with the servers but as to what I do not know. Any ideas?