Search code examples
orchardcms

Orchard CMS: Modules enabling or disabling not working


I have a web site built with Orchard CMS (v.1.10.2.0); I developed a custom module and installed it, and it is working, like other modules already installed.

My problem is that, starting from sometimes ago (I don't know exactly from when), if I try to enable or disable a module I encounter always an error about JetBrains.Annotations (see below for the full stack).

I can't debug the site (it is published on a server, it's not running on my machine); anyone knows how can I understand what problem is going on? Any advice on how to gain some information without debugging? (I'm quite new to Orchard).

Oops. Something went wrong ... sorry An unhandled exception has occurred and the request was terminated. Please refresh the page. If the error persists, go back

One or more errors occurred.

System.AggregateException: One or more errors occurred. ---> System.TypeLoadException: Could not load type 'JetBrains.Annotations.UsedImplicitlyAttribute' from assembly 'Orchard.Framework, Version=1.10.2.0, Culture=neutral, PublicKeyToken=null'. at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit) at Orchard.Environment.Extensions.ExtensionManager.GetSourceFeatureNameForType(Type type, String extensionId) at Orchard.Environment.Extensions.ExtensionManager.LoadFeature(FeatureDescriptor featureDescriptor) at Orchard.Caching.Cache2.CreateEntry(TKey k, Func2 acquire) at Orchard.Caching.Cache2.<>c__DisplayClass3_0.<Get>b__0(TKey k) at System.Collections.Concurrent.ConcurrentDictionary2.AddOrUpdate(TKey key, Func2 addValueFactory, Func3 updateValueFactory) at Orchard.Caching.Cache2.Get(TKey key, Func2 acquire) at Orchard.Caching.CacheManagerExtensions.Get[TKey,TResult](ICacheManager cacheManager, TKey key, Boolean preventConcurrentCalls, Func2 acquire) at Orchard.Environment.Extensions.ExtensionManager.<LoadFeatures>b__19_0(FeatureDescriptor descriptor) at Orchard.Caching.DefaultParallelCacheContext.TaskWithAcquireContext1.Execute() at System.Linq.Parallel.ArrayMergeHelper1.ToArrayElement(Int32 index) at System.Linq.Parallel.ForAllOperator1.ForAllEnumerator1.MoveNext(TInput& currentElement, Int32& currentKey) at System.Linq.Parallel.ForAllSpoolingTask2.SpoolingWork() at System.Linq.Parallel.SpoolingTaskBase.Work() at System.Linq.Parallel.QueryTask.BaseWork(Object unused) at System.Threading.Tasks.Task.Execute() --- End of inner exception stack trace --- at System.Linq.Parallel.QueryTaskGroupState.QueryEnd(Boolean userInitiatedDispose) at System.Linq.Parallel.DefaultMergeHelper2.System.Linq.Parallel.IMergeHelper<TInputOutput>.Execute() at System.Linq.Parallel.MergeExecutor1.Execute[TKey](PartitionedStream2 partitions, Boolean ignoreOutput, ParallelMergeOptions options, TaskScheduler taskScheduler, Boolean isOrdered, CancellationState cancellationState, Int32 queryId) at System.Linq.Parallel.PartitionedStreamMerger1.Receive[TKey](PartitionedStream2 partitionedStream) at System.Linq.Parallel.ForAllOperator1.WrapPartitionedStream[TKey](PartitionedStream2 inputStream, IPartitionedStreamRecipient1 recipient, Boolean preferStriping, QuerySettings settings) at System.Linq.Parallel.UnaryQueryOperator2.UnaryQueryOperatorResults.ChildResultsRecipient.Receive[TKey](PartitionedStream2 inputStream) at System.Linq.Parallel.ScanQueryOperator1.ScanEnumerableQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient1 recipient) at System.Linq.Parallel.UnaryQueryOperator2.UnaryQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient1 recipient) at System.Linq.Parallel.QueryOperator1.GetOpenedEnumerator(Nullable1 mergeOptions, Boolean suppressOrder, Boolean forEffect, QuerySettings querySettings) at System.Linq.Parallel.ForAllOperator1.RunSynchronously() at System.Linq.Parallel.ArrayMergeHelper1.Execute() at System.Linq.Parallel.QueryOperator1.ExecuteAndGetResultsAsArray() at Orchard.Caching.DefaultParallelCacheContext.RunInParallel[T,TResult](IEnumerable1 source, Func2 selector) at Orchard.Environment.Extensions.ExtensionManager.LoadFeatures(IEnumerable1 featureDescriptors) at System.Linq.Enumerable.d__172.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at Orchard.Modules.Controllers.AdminController.FeaturesPOST(FeaturesBulkAction bulkAction, IList1 featureIds, Nullable1 force) at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() ---> (Inner Exception #0) System.TypeLoadException: Could not load type 'JetBrains.Annotations.UsedImplicitlyAttribute' from assembly 'Orchard.Framework, Version=1.10.2.0, Culture=neutral, PublicKeyToken=null'. at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit) at Orchard.Environment.Extensions.ExtensionManager.GetSourceFeatureNameForType(Type type, String extensionId) at Orchard.Environment.Extensions.ExtensionManager.LoadFeature(FeatureDescriptor featureDescriptor) at Orchard.Caching.Cache2.CreateEntry(TKey k, Func2 acquire) at Orchard.Caching.Cache2.<>c__DisplayClass3_0.b__0(TKey k) at System.Collections.Concurrent.ConcurrentDictionary2.AddOrUpdate(TKey key, Func2 addValueFactory, Func3 updateValueFactory) at Orchard.Caching.Cache2.Get(TKey key, Func2 acquire) at Orchard.Caching.CacheManagerExtensions.Get[TKey,TResult](ICacheManager cacheManager, TKey key, Boolean preventConcurrentCalls, Func2 acquire) at Orchard.Environment.Extensions.ExtensionManager.b__19_0(FeatureDescriptor descriptor) at Orchard.Caching.DefaultParallelCacheContext.TaskWithAcquireContext1.Execute() at System.Linq.Parallel.ArrayMergeHelper1.ToArrayElement(Int32 index) at System.Linq.Parallel.ForAllOperator1.ForAllEnumerator1.MoveNext(TInput& currentElement, Int32& currentKey) at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork() at System.Linq.Parallel.SpoolingTaskBase.Work() at System.Linq.Parallel.QueryTask.BaseWork(Object unused) at System.Threading.Tasks.Task.Execute()<---


Solution

  • I encountered this issue a few times. The problem is that the Extension Manager tries to load an assembly (probably a custom module) that contains references to JetBrains annotation classes which were compiled into the Orchard.Framework assembly but were removed at some point due to conflicts with other assemblies which contained classes with the same name.

    The only solution I found was to remove all usages of JetBrains annotation attributes from custom modules.