Running Orchard 1.5.1 throws exceptions

Topics: Administration, Announcements, Core, Customizing Orchard, Francais (French), General, Installing Orchard, Jobs, Localization, Troubleshooting, Writing modules, Writing themes, Русский (Russian), 中文(Chinese)
Aug 9, 2012 at 4:24 PM
Edited Aug 10, 2012 at 8:32 AM

When we download this file: http://orchard.codeplex.com/downloads/get/461850 and unzip it, load it in VS 2010 Professional, run it...

We get lots of exceptions being thrown in DefaultExtensionCompiler.Compile(CompileExtensionContext context).

What can we do about this? We're loading the project exactly as it is in the .zip file, we have not modified any file.

Assembly reference 'Lucene.Net' for project '/OrchardLocal/Modules/Lucene/Lucene.csproj' cannot be loadedError compiling module "Lucene" from file "/OrchardLocal/Modules/Lucene/Lucene.csproj":Assembly reference 'Lucene.Net' for project '/OrchardLocal/Modules/Lucene/Lucene.csproj' cannot be loadedAssembly reference 'MarkdownSharp' for project '/OrchardLocal/Modules/Markdown/Markdown.csproj' cannot be loadedError compiling module "Markdown" from file "/OrchardLocal/Modules/Markdown/Markdown.csproj":Assembly reference 'MarkdownSharp' for project '/OrchardLocal/Modules/Markdown/Markdown.csproj' cannot be loadedAssembly reference 'Joel.Net.Akismet, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL' for project '/OrchardLocal/Modules/Orchard.Comments/Orchard.Comments.csproj' cannot be loadedError compiling module "Orchard.Comments" from file "/OrchardLocal/Modules/Orchard.Comments/Orchard.Comments.csproj":Assembly reference 'Joel.Net.Akismet, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL' for project '/OrchardLocal/Modules/Orchard.Comments/Orchard.Comments.csproj' cannot be loadedAssembly reference 'ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL' for project '/OrchardLocal/Modules/Orchard.Media/Orchard.Media.csproj' cannot be loadedError compiling module "Orchard.Media" from file "/OrchardLocal/Modules/Orchard.Media/Orchard.Media.csproj":Assembly reference 'ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL' for project '/OrchardLocal/Modules/Orchard.Media/Orchard.Media.csproj' cannot be loadedAssembly reference 'ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL' for project '/OrchardLocal/Modules/Orchard.Media/Orchard.Media.csproj' cannot be loadedError compiling module "Orchard.Media" from file "/OrchardLocal/Modules/Orchard.Media/Orchard.Media.csproj":Assembly reference 'ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL' for project '/OrchardLocal/Modules/Orchard.Media/Orchard.Media.csproj' cannot be loadedAssembly reference 'Orchard.Media' for project '/OrchardLocal/Modules/Orchard.MediaPicker/Orchard.MediaPicker.csproj' cannot be loadedError compiling module "Orchard.MediaPicker" from file "/OrchardLocal/Modules/Orchard.MediaPicker/Orchard.MediaPicker.csproj":Assembly reference 'Orchard.Media' for project '/OrchardLocal/Modules/Orchard.MediaPicker/Orchard.MediaPicker.csproj' cannot be loadedAssembly reference 'IronRuby, Version=1.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL' for project '/OrchardLocal/Modules/Orchard.Scripting.Dlr/Orchard.Scripting.Dlr.csproj' cannot be loadedError compiling module "Orchard.Scripting.Dlr" from file "/OrchardLocal/Modules/Orchard.Scripting.Dlr/Orchard.Scripting.Dlr.csproj":Assembly reference 'IronRuby, Version=1.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL' for project '/OrchardLocal/Modules/Orchard.Scripting.Dlr/Orchard.Scripting.Dlr.csproj' cannot be loaded

Developer
Aug 9, 2012 at 7:20 PM

I have no idea, but what happens if you first build the solution and then run it?

Aug 9, 2012 at 10:57 PM

You are using VS2008 for .NET 4 developement?

Aug 10, 2012 at 8:22 AM

Hi, thanks for the replies.

No, I'm using Visual Studio 2010 Professional for .NET 4 development.

If I first build the solution and then run the site, I still get the same exceptions.

It somehow seems it tries to load assemblies that it can't find. Or something like that.

Aug 10, 2012 at 8:32 AM

I see I said I'm using VS 2008, but I'm using 2010. Not 2008.

Aug 10, 2012 at 9:00 AM
Edited Aug 10, 2012 at 9:01 AM

I just added Lucene.Net, ICSharpCode.SharpZipLib, MarkdownSharp, etc. as reference to Orchard.Web, now it works without exceptions.

I suppose this is not how it should work. I suppose it should "find" the references from other projects. However, that's not working for us.

Aug 10, 2012 at 1:20 PM

The source zip is just that - source - you need to build (rebuild) all the projects in the solution so that all the dependant dlls are in each of the modules local bin directory - just as installing a module includes all dependencies (non orchard) in the package.

The application startup process will dynamically compile (if necessary) each module and copy it and its dependencies from the modules local bin directory to the dependencies directory in App_data - but these do not exist in the source zip file until the whole solution is built.

The extra references in Orchard.Web are not necessary - this will copy the modules dependant dlls to the Application bin directory with the core dlls rather than the App_data/dependencies as designed.

Aug 10, 2012 at 4:13 PM

"The application startup process will dynamically compile (if necessary) each module and copy it and its dependencies from the modules local bin directory to the dependencies directory in App_data - but these do not exist in the source zip file until the whole solution is built."

And exactly that is what is going wrong. Somehow Orchard can't find the dll-files. Even when I rebuild the entire solution and then run Orchard.Web. Only when adding the references to Orchard.Web itself, it works.

Aug 10, 2012 at 6:24 PM

Sounds like you are only building Orchard.Web and its dependencies rather than the entire solution - you can check by browsing the all the Modules directories under Orchard.web - there should be a bin directory under each one.

Modules/Lucene/bin should contain Lucene.Net.dll, Modules/Markdown/bin MarkdownSharp.dll, Modules/Orchard.Media/bin ICSharpCode.SharpZipLib.dll, etc.

I've just copied the the Orchard.Source.1.5.1.zip from the link you provided, unzipped and opened in VS2010, Rebuild Solution (65+ projects) and run and setup a new website without error.

Aug 17, 2012 at 8:44 AM

Hi, thanks for your reply. Don't you have the Lucene DLLs and everything in the GAC?

If I do the same, everything builds fine. But when I access the website, it tries to load Lucene, MarkdownSharp, SharpZipLib, etc. and those fail.

Aug 17, 2012 at 6:07 PM

NO - no deployment to the GAC is necessary, Orchard uses local bin deployment, and each module and theme has its own local bin for any of its dependencies - this is the bit missing when trying to run the website from the source zip.

It's the same advice as before -  I can replicate the error by unzipping the Source file, opening the Orchard Solution and running Orchard.Web. Orchard builds the modules with exceptions - it cannot resolve the dependencies, Lucene.Net.dll, MarkdownSharp.dll, ICSharpCode.SharpZipLib.dll, etc,, as expected they do not exist within the website - I had not built Lucene, Markdown, Orchard.Media, Orchard.Comments, etc, in VS, only Orchard.Web (and dependencies).

It may look like you have built all the necessary projects - browsing the folders you will find bin directories under each module but look closely and you may only find copies of dlls from the website root bin folder (Orchard.Web\bin) no module dll or other dependant dlls from the lib folder.

 

That is the reason I suggested you check the dlls are in the correct folder in the website  - they will only be there if you have built all the modules in VS (Build Solution Ctrl+Shift+B) or unzipped and copied a module package - check for the existence of 

...Orchard.Web\Modules\Lucene\bin\Lucene.Net.dll (not Lucene.dll)

...Orchard.Web\Modules\Markdown\bin\MarkdownSharp.dll (not Markdown.dll)

...Orchard.Web\Modules\Orchard.Media\bin\ICSharpCode.SharpZipLib.dll,

...Orchard.Web\Modules\........\bin\....... etc

These files will only exist from a source deployment if you have used VS to build, at least once, each Module, that has dlls dependencies other than Orchard core - this will copy the dependent dlls from the lib folders to the relevant Module bin folder.

Take a look at Orchard.Web.zip which is pre-built ready for deployment to a server - each module has a bin folder with the necessary dependant dlls - the same as installing from a package.

If the dependant dlls are not in bin folder of the module itself the dynamic loader will not be able to find them when the application is run in the web server - it can only see folders within the website (Orchard.Web is the root) to resolve dependencies, not the lib folders which are part of the source zip file accessible to VS but external to the website. The dynamic load process tries to resolve all the project references to files local to the web app.

In the case of Lucene the dynamic loader will attempt copy Lucene.Net.dll from ~/Modules/Lucene/bin to ~/App_Data/Dependencies.

Building the Lucene module and running Orchard.Web again - Lucene.Net.dll is not longer reported as missing and is copied along with Lucene.dll to ~/App_Data/Dependencies.

Sep 12, 2012 at 8:59 PM

I had the same error, and as filetek pointed out, solution has to be built at least once.