Orchard looking for System.Web.Mvc Version 4.0.0.0

Topics: Troubleshooting
Dec 15, 2011 at 6:11 PM

The Solution will run from VS but when I put it on the stage server (WS2008) I get this error

Could not load file or assembly 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Any ideas?

Coordinator
Dec 15, 2011 at 8:42 PM

Check that the application is running in an app pool that is setup for .net 4.0.

Dec 15, 2011 at 9:49 PM

The app pool is .NET 4.0 and Integrated Pipeline with 32 bit applications enabled = true.

Coordinator
Dec 15, 2011 at 9:54 PM

Then it's probably an incomplete deployment. You are probably missing dlls in bin, in particular.

How did you deploy by the way?

Dec 15, 2011 at 10:51 PM
Edited Dec 15, 2011 at 10:53 PM

All the needed assemblies are in the bin, also the server the site is being deployed on has MVC installed so the MVC bits are in the GAC. I made a few tweaks to the Orchard.proj and am using the ClickToBuild.cmd to to build the site. The changes were small, just to remove the .svn dirs (sad I know) and move a few other files. I am deploying the contents of the Stage dir.

 

Here is the stack trace, if it helps:

 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.

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].


Stack Trace:

[FileLoadException: Could not load file or assembly 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes) +0
   System.Reflection.RuntimeAssembly.GetExportedTypes() +38
   Orchard.Environment.Extensions.Loaders.PrecompiledExtensionLoader.LoadWorker(ExtensionDescriptor descriptor) in s:\development\work\RTB\src\Orchard\Environment\Extensions\Loaders\PrecompiledExtensionLoader.cs:228
   Orchard.Environment.Extensions.Loaders.ExtensionLoaderBase.Load(ExtensionDescriptor descriptor) in s:\development\work\RTB\src\Orchard\Environment\Extensions\Loaders\ExtensionLoaderBase.cs:37
   Orchard.Environment.Extensions.ExtensionManager.BuildEntry(ExtensionDescriptor descriptor) in s:\development\work\RTB\src\Orchard\Environment\Extensions\ExtensionManager.cs:160
   Orchard.Environment.Extensions.<>c__DisplayClass1c.<LoadFeature>b__16(AcquireContext`1 ctx) in s:\development\work\RTB\src\Orchard\Environment\Extensions\ExtensionManager.cs:110
   Orchard.Caching.Cache`2.CreateEntry(TKey k, Func`2 acquire) in s:\development\work\RTB\src\Orchard\Caching\Cache.cs:57
   Orchard.Caching.<>c__DisplayClass2.<Get>b__0(TKey k) in s:\development\work\RTB\src\Orchard\Caching\Cache.cs:19
   System.Collections.Concurrent.ConcurrentDictionary`2.AddOrUpdate(TKey key, Func`2 addValueFactory, Func`3 updateValueFactory) +125
   Orchard.Caching.Cache`2.Get(TKey key, Func`2 acquire) in s:\development\work\RTB\src\Orchard\Caching\Cache.cs:17
   Orchard.Caching.DefaultCacheManager.Get(TKey key, Func`2 acquire) in s:\development\work\RTB\src\Orchard\Caching\DefaultCacheManager.cs:33
   Orchard.Environment.Extensions.ExtensionManager.LoadFeature(FeatureDescriptor featureDescriptor) in s:\development\work\RTB\src\Orchard\Environment\Extensions\ExtensionManager.cs:109

[OrchardException: Error while loading extension 'Contrib.Taxonomies'.]
   Orchard.Environment.Extensions.ExtensionManager.LoadFeature(FeatureDescriptor featureDescriptor) in s:\development\work\RTB\src\Orchard\Environment\Extensions\ExtensionManager.cs:123
   Orchard.Environment.Extensions.<>c__DisplayClass12.<LoadFeatures>b__11(AcquireContext`1 ctx) in s:\development\work\RTB\src\Orchard\Environment\Extensions\ExtensionManager.cs:95
   Orchard.Caching.Cache`2.CreateEntry(TKey k, Func`2 acquire) in s:\development\work\RTB\src\Orchard\Caching\Cache.cs:57
   Orchard.Caching.<>c__DisplayClass2.<Get>b__0(TKey k) in s:\development\work\RTB\src\Orchard\Caching\Cache.cs:19
   System.Collections.Concurrent.ConcurrentDictionary`2.AddOrUpdate(TKey key, Func`2 addValueFactory, Func`3 updateValueFactory) +125
   Orchard.Caching.Cache`2.Get(TKey key, Func`2 acquire) in s:\development\work\RTB\src\Orchard\Caching\Cache.cs:17
   Orchard.Caching.DefaultCacheManager.Get(TKey key, Func`2 acquire) in s:\development\work\RTB\src\Orchard\Caching\DefaultCacheManager.cs:33
   Orchard.Environment.Extensions.ExtensionManager.<LoadFeatures>b__10(FeatureDescriptor descriptor) in s:\development\work\RTB\src\Orchard\Environment\Extensions\ExtensionManager.cs:95
   Orchard.Caching.<>c__DisplayClass7.<RunInParallel>b__1() in s:\development\work\RTB\src\Orchard\Caching\DefaultParallelCacheContext.cs:24
   Orchard.Caching.TaskWithAcquireContext`1.Execute() in s:\development\work\RTB\src\Orchard\Caching\DefaultParallelCacheContext.cs:71
   Orchard.Caching.DefaultParallelCacheContext.<RunInParallel>b__2(ITask`1 task) in s:\development\work\RTB\src\Orchard\Caching\DefaultParallelCacheContext.cs:30
   System.Linq.Parallel.SelectQueryOperatorResults.GetElement(Int32 index) +32
   System.Linq.Parallel.ArrayMergeHelper`1.ToArrayElement(Int32 index) +22
   System.Linq.Parallel.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey) +83
   System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork() +45
   System.Linq.Parallel.SpoolingTaskBase.Work() +184
   System.Linq.Parallel.QueryTask.BaseWork(Object unused) +65
   System.Linq.Parallel.QueryTask.<.cctor>b__0(Object o) +41
   System.Threading.Tasks.Task.InnerInvoke() +67
   System.Threading.Tasks.Task.Execute() +66

[AggregateException: One or more errors occurred.]
   System.Linq.Parallel.QueryTaskGroupState.QueryEnd(Boolean userInitiatedDispose) +274
   System.Linq.Parallel.SpoolingTask.SpoolForAll(QueryTaskGroupState groupState, PartitionedStream`2 partitions, TaskScheduler taskScheduler) +130
   System.Linq.Parallel.DefaultMergeHelper`2.System.Linq.Parallel.IMergeHelper<TInputOutput>.Execute() +80
   System.Linq.Parallel.MergeExecutor`1.Execute(PartitionedStream`2 partitions, Boolean ignoreOutput, ParallelMergeOptions options, TaskScheduler taskScheduler, Boolean isOrdered, CancellationState cancellationState, Int32 queryId) +310
   System.Linq.Parallel.PartitionedStreamMerger`1.Receive(PartitionedStream`2 partitionedStream) +34
   System.Linq.Parallel.ForAllOperator`1.WrapPartitionedStream(PartitionedStream`2 inputStream, IPartitionedStreamRecipient`1 recipient, Boolean preferStriping, QuerySettings settings) +232
   System.Linq.Parallel.ChildResultsRecipient.Receive(PartitionedStream`2 inputStream) +77
   System.Linq.Parallel.ScanEnumerableQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient`1 recipient) +77
   System.Linq.Parallel.UnaryQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient`1 recipient) +390
   System.Linq.Parallel.QueryOperator`1.GetOpenedEnumerator(Nullable`1 mergeOptions, Boolean suppressOrder, Boolean forEffect, QuerySettings querySettings) +364
   System.Linq.Parallel.ForAllOperator`1.RunSynchronously() +201
   System.Linq.ParallelEnumerable.ForAll(ParallelQuery`1 source, Action`1 action) +242
   System.Linq.Parallel.ArrayMergeHelper`1.Execute() +388
   System.Linq.Parallel.QueryOperator`1.ExecuteAndGetResultsAsArray() +602
   System.Linq.ParallelEnumerable.ToArray(ParallelQuery`1 source) +71
   Orchard.Caching.DefaultParallelCacheContext.RunInParallel(IEnumerable`1 source, Func`2 selector) in s:\development\work\RTB\src\Orchard\Caching\DefaultParallelCacheContext.cs:27
   Orchard.Environment.Extensions.ExtensionManager.LoadFeatures(IEnumerable`1 featureDescriptors) in s:\development\work\RTB\src\Orchard\Environment\Extensions\ExtensionManager.cs:93
   Orchard.Environment.ShellBuilders.CompositionStrategy.Compose(ShellSettings settings, ShellDescriptor descriptor) in s:\development\work\RTB\src\Orchard\Environment\ShellBuilders\CompositionStrategy.cs:43
   Orchard.Environment.ShellBuilders.ShellContextFactory.CreateShellContext(ShellSettings settings) in s:\development\work\RTB\src\Orchard\Environment\ShellBuilders\ShellContextFactory.cs:60
   Orchard.Environment.DefaultOrchardHost.CreateShellContext(ShellSettings settings) in s:\development\work\RTB\src\Orchard\Environment\DefaultOrchardHost.cs:168
   Orchard.Environment.DefaultOrchardHost.CreateAndActivateShells() in s:\development\work\RTB\src\Orchard\Environment\DefaultOrchardHost.cs:132
   Orchard.Environment.DefaultOrchardHost.BuildCurrent() in s:\development\work\RTB\src\Orchard\Environment\DefaultOrchardHost.cs:103
   Orchard.Environment.DefaultOrchardHost.Orchard.Environment.IOrchardHost.Initialize() in s:\development\work\RTB\src\Orchard\Environment\DefaultOrchardHost.cs:67
   Orchard.Web.MvcApplication.HostInitialization(HttpApplication application) in s:\development\work\RTB\src\Orchard.Web\Global.asax.cs:48
   Orchard.WarmupStarter.<>c__DisplayClass3.<LaunchStartupThread>b__2(Object state) in s:\development\work\RTB\src\Orchard.Startup\Starter.cs:89

[ApplicationException: Error during application initialization]
   Orchard.WarmupStarter.Starter`1.OnBeginRequest(HttpApplication application) in s:\development\work\RTB\src\Orchard.Startup\Starter.cs:63
   Orchard.Web.MvcApplication.Application_BeginRequest() in s:\development\work\RTB\src\Orchard.Web\Global.asax.cs:29

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner) +0
   System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner) +72
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +335
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +28
   System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +19
   System.Web.Util.ArglessEventHandlerProxy.Callback(Object sender, EventArgs e) +57
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
Coordinator
Dec 15, 2011 at 10:58 PM

Well, it can't find that dll. So maybe it doesn't even find bin. That could be the case if the directory where you deployed (and wehre bin should be) is not an IIS application.

Dec 15, 2011 at 11:34 PM
Edited Dec 15, 2011 at 11:38 PM

Just not sure why it wants a Version 4.0.0.0 of System.Web.Mvc when Orchard is using Version 3.0.0.0

Coordinator
Dec 15, 2011 at 11:36 PM

Ha! How did I miss that? The one you have in the gac, is it some pre-version of MVC 4?

Dec 15, 2011 at 11:48 PM

I have been playing with the dev-preview of .NET 4.5, MVC4 and Windows 8 on my local box. However, the server does not have the dev-previews installed. Could it be 0the build is using a different compiler made for .NET 4.5 and is somehow using MVC4?

Coordinator
Dec 15, 2011 at 11:51 PM

That would explain it. Somebody somewhere made the rather idiotic decision that the GAC would always win over local copies of dlls unless a specific version is specified. Your local build of Orchard was thus made and bound against a 4.x version. When you deploy, it's asking for that version because that's what it's built against, and because it's not there, it fails.

Easiest thing to do is to uninstall that thing from your build machine and rebuild and redeploy.

Dec 16, 2011 at 12:02 AM
Edited Dec 16, 2011 at 12:17 AM

Wow, I always assumed the local copy would always take priority over the GAC. I removed the entry from the GAC on my dev box and will rebuild.

For anyone who runs into this, run this command from the VS Command Prompt"

gacutil /u System.Web.Mvc,Version=4.0.0.0,Culture="neutral",PublicKeyToken=31bf3856ad364e35

Augh, dependencies! The above command will not work. You just need to uninstall MVC4.