Assembly references can't be loaded for deployed site

Topics: Troubleshooting
Developer
Jun 25, 2012 at 5:08 PM
Edited Jun 25, 2012 at 6:42 PM

I recently deployed a site to Gearhost that uses an SQL Server database. Locally everything works fine (with Cassini and IIS Express too), but deployed I get errors of the "The assembly reference ... could not be loaded for module ...." type. Previously I experienced a similar error, that Media couldn't be loaded for MediaPicker, the current one is "The assembly reference 'Joel.Net.Akismet, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL' could not be loaded for module 'Orchard.Comments'.".

Looking at the logs (see the entries below) it seems that all references specified in module or theme csprojs, project references and dll references also, fail.

This issue is about the same problem. I've tried removing the Dependencies folder and cleaning/rebuilding multiple times, without luck.

Formerly with SQL Server CE there were no such errors.

Any help would be greatly appreciated!

 

Log entries below. The first one starts the row, actually it goes on for kilometers listing practically every assembly.

 

2012-06-25 08:26:04,895 [59] Orchard.Environment.DefaultAssemblyLoader - Error loading assembly 'ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL'
System.IO.FileNotFoundException: Could not load file or assembly 'ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73' or one of its dependencies. The system cannot find the file specified.
File name: 'ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73'
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
   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 D:\src\Orchard\Environment\IAssemblyLoader.cs:line 56
   at Orchard.Environment.DefaultAssemblyLoader.<>c__DisplayClass4.b__2(String shortName) in D:\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 D:\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].

2012-06-25 08:26:05,098 [59] Orchard.Environment.Extensions.Compilers.DefaultExtensionCompiler - Assembly reference 'ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL' for project '/Modules/Orchard.Media/Orchard.Media.csproj' cannot be loaded
2012-06-25 08:26:05,254 [59] Orchard.Environment.DefaultAssemblyLoader - Error loading assembly 'ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL'
System.IO.FileNotFoundException: Could not load file or assembly 'ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73' or one of its dependencies. The system cannot find the file specified.
File name: 'ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73'
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
   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 D:\src\Orchard\Environment\IAssemblyLoader.cs:line 56
   at Orchard.Environment.DefaultAssemblyLoader.<>c__DisplayClass4.b__2(String shortName) in D:\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 D:\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].

2012-06-25 08:26:05,254 [59] Orchard.Environment.Extensions.Compilers.DefaultExtensionCompiler - Assembly reference 'ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL' for project '/Modules/Orchard.Media/Orchard.Media.csproj' cannot be loaded
2012-06-25 08:26:05,254 [59] Orchard.Environment.Extensions.ExtensionManager - No suitable loader found for extension "Orchard.Media"
2012-06-25 08:26:05,300 [62] Orchard.Environment.DefaultAssemblyLoader - Error loading assembly 'Lucene.Net'
System.IO.FileNotFoundException: Could not load file or assembly 'Lucene.Net' or one of its dependencies. The system cannot find the file specified.
File name: 'Lucene.Net'
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
   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 D:\Orchard\Environment\IAssemblyLoader.cs:line 56
   at Orchard.Environment.DefaultAssemblyLoader.<>c__DisplayClass4.b__2(String shortName) in D:\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 D:\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].

2012-06-25 08:26:05,300 [62] Orchard.Environment.Extensions.Compilers.DefaultExtensionCompiler - Assembly reference 'Lucene.Net' for project '/Modules/Lucene/Lucene.csproj' cannot be loaded
2012-06-25 08:26:05,332 [62] Orchard.Environment.DefaultAssemblyLoader - Error loading assembly 'Lucene.Net'
System.IO.FileNotFoundException: Could not load file or assembly 'Lucene.Net' or one of its dependencies. The system cannot find the file specified.
File name: 'Lucene.Net'
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
   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 D:\Orchard\Environment\IAssemblyLoader.cs:line 56
   at Orchard.Environment.DefaultAssemblyLoader.<>c__DisplayClass4.b__2(String shortName) in D:\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 D:\Orchard\Environment\IAssemblyLoader.cs:line 26

Jun 25, 2012 at 7:47 PM

You need to copy the dl files for all assemblys that the log says not could be loaded.

 

Example Lucene.Net dll files, you finding all dll files in the lib folder in the source, the problem, like i describe in the issue you linking to is that the Orchard.Web project dont has references to all binaries that are needed example Lucene.Net

I got all to work after checked the logs after readed this thread.

Developer
Jun 25, 2012 at 8:51 PM

Thanks! Wow, now I'm feeling dumb, because indeed, there are no bin folders even on the server in module directories, also not in the deploy package created. But I don't know why this worked previously, as I haven't changed anything about deployment.

But shouldn't VS deploy everything that's referenced in project files? And those dlls are. I don't understand.

Jun 25, 2012 at 9:19 PM

The problem is that Orchard.Web project in the source code has no reference to all binaries that it need. 

So thats why publish not copy all binaries.

Developer
Jun 25, 2012 at 10:28 PM

Thanks, indeed. Surprisingly changing publish options to even include everything in the project folder doesn't help.

I hope the only option is not to include all missing binaries by hand in the Orchard.Web project!

Coordinator
Jun 25, 2012 at 10:30 PM

There is a specific alteration to the project file in regards to WebDeploy which tells it to also include the binaries and other necessary items. So if you use it in release mode it should contains everything. Though I tried it this morning and it didn't seem to work anymore if I target something else that the FileSystem. I hope it's not because of the latest update of WebDeploy in Visual Studio.

Developer
Jun 25, 2012 at 10:47 PM
Edited Jun 25, 2012 at 10:52 PM

Oh awesome, I didn't know that. So this is the type of feature that goes unnoticed until not working. I tried this in Release mode with WebDeploy, this is having the issue for me too. I also tried to publish to the file system but am experiencing the same with the publish options set to only include files necessary for running the site (I believe I've never used anything previously, when I succeeded).

What seems to only work is to use "All files in the project folder" when publishing to the file system.

Developer
Jun 27, 2012 at 4:50 PM

What I did now is the following: published the deployed package with the above mentioned "All files in the project folder" option to the local file system, then uploaded this with FTP. This way the modules' bin folders were full of redundant dlls, not just their unique custom dependencies. This package is unfortunately 750MB big.

Developer
Jun 27, 2012 at 7:09 PM

OK, now it turns out that with "Only files needed with this application" works just fine too, if the site is run at least once. Otherwise (so e.g. after a fresh clean, without running, just building) the binary module dependencies don't get included in the package.