Error loading assembly

Topics: Customizing Orchard, Installing Orchard, Troubleshooting
Apr 22, 2014 at 6:06 PM
I have a site that was running 1.7.0 and had hosted and was working. I recently tried upgrading this to 1.7.2 and then 1.8.0. I've followed all of the instructions and the upgrade appears to have gone smoothly (locally) ...

I have a custom module that references Orchard.Users and Orchard.Roles. Locally the site works fine. But after running ClickToBuild.cmd and deploying the site to my host I get a 404 error.

I checked the logs and see the following errors:
2014-04-22 11:41:03,002 [21] Orchard.Environment.Extensions.Compilers.DefaultExtensionCompiler - (null) - Assembly reference 'Orchard.Roles' for project '/Modules/ABC.XYZ/ABC.XYZ.csproj' cannot be loaded
 (null)
2014-04-22 11:41:03,057 [21] Orchard.Environment.DefaultAssemblyLoader - (null) - Error loading assembly 'Orchard.Roles'
 (null)
System.IO.FileNotFoundException: Could not load file or assembly 'Orchard.Roles' or one of its dependencies. The system cannot find the file specified.
File name: 'Orchard.Roles'
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.Load(String assemblyString)
   at Orchard.Environment.DefaultAssemblyLoader.LoadWorker(String shortName, String fullName) in c:\Src\Git\abcxyz\src\Orchard\Environment\IAssemblyLoader.cs:line 56
   at Orchard.Environment.DefaultAssemblyLoader.<>c__DisplayClass4.<Load>b__2(String shortName) in c:\Src\Git\abcxyz\src\Orchard\Environment\IAssemblyLoader.cs:line 26
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Orchard.Environment.DefaultAssemblyLoader.Load(String assemblyName) in c:\Src\Git\abcxyz\src\Orchard\Environment\IAssemblyLoader.cs:line 26

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

2014-04-22 11:41:03,062 [21] Orchard.Environment.Extensions.Compilers.DefaultExtensionCompiler - (null) - Assembly reference 'Orchard.Roles' for project '/Modules/ABC.XYZ/ABC.XYZ.csproj' cannot be loaded
 (null)
2014-04-22 11:41:03,084 [11] Orchard.Environment.DefaultAssemblyLoader - (null) - Error loading assembly 'Orchard.Users'
 (null)
System.IO.FileNotFoundException: Could not load file or assembly 'Orchard.Users' or one of its dependencies. The system cannot find the file specified.
File name: 'Orchard.Users'
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.Load(String assemblyString)
   at Orchard.Environment.DefaultAssemblyLoader.LoadWorker(String shortName, String fullName) in c:\Src\Git\abcxyz\src\Orchard\Environment\IAssemblyLoader.cs:line 56
   at Orchard.Environment.DefaultAssemblyLoader.<>c__DisplayClass4.<Load>b__2(String shortName) in c:\Src\Git\abcxyz\src\Orchard\Environment\IAssemblyLoader.cs:line 26
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Orchard.Environment.DefaultAssemblyLoader.Load(String assemblyName) in c:\Src\Git\abcxyz\src\Orchard\Environment\IAssemblyLoader.cs:line 26

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
I've made sure the Orchard.Users.dll and Orchard.Roles.dll are in my bin folder for this module. I tried copying them to the main bin. Tried copying them to the Dependencies folder. Nothing seems to work.

It probably is not related, but prior to the upgrade this custom module was targeting .NET 4.0. After the upgrade I noticed a yellow warning icon on the references for Users and Roles. I switched the Target Framework to 4.5 for my assembly to match Orchard and this problem went away.

Is there anyone that can provide some insight into this problem? I'm at a loss.