Operation could destabilize the runtime.

Topics: General, Troubleshooting, Writing modules
Mar 23, 2011 at 3:11 PM

I'm trying to debug my orchard module and I keep getting a "Operation could destabilize the runtime" exception when trying to load up the site.  It seems to happen on code that is not included in the solution.  If I run the site without debuging everything works great. 

 

   at Orchard.ContentManagement.ContentItem.Get(Type partType) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\ContentManagement\ContentItem.cs:line 35   at Orchard.ContentManagement.ContentExtensions.As[T](IContent content) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\ContentManagement\ContentExtensions.cs:line 198   at Orchard.ContentManagement.ContentExtensions.<AsPart>b__7[T](ContentItem item) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\ContentManagement\ContentExtensions.cs:line 209   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)   at Orchard.Core.Settings.Services.SiteService.<GetSiteSettings>b__0(AcquireContext`1 ctx) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard.Web\Core\Settings\Services\SiteService.cs:line 30   at Orchard.Caching.Cache`2.CreateEntry(TKey k, Func`2 acquire) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\Caching\Cache.cs:line 41   at Orchard.Caching.Cache`2.<>c__DisplayClass3.<Get>b__0(TKey k) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\Caching\Cache.cs:line 17   at System.Collections.Concurrent.ConcurrentDictionary`2.AddOrUpdate(TKey key, Func`2 addValueFactory, Func`3 updateValueFactory)   at Orchard.Caching.Cache`2.Get(TKey key, Func`2 acquire) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\Caching\Cache.cs:line 15   at Orchard.Caching.DefaultCacheManager.Get[TKey,TResult](TKey key, Func`2 acquire) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\Caching\DefaultCacheManager.cs:line 33   at Orchard.Core.Settings.Services.SiteService.GetSiteSettings() in d:\TeamCity\Projects\Orchard-1.x\src\Orchard.Web\Core\Settings\Services\SiteService.cs:line 29   at Orchard.Settings.CurrentSiteWorkContext.Get[T](String name) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\Settings\CurrentSiteWorkContext.cs:line 13   at Orchard.Environment.WorkContextImplementation.<>c__DisplayClass7`1.<FindResolverForState>b__2(IWorkContextStateProvider wcsp) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\Environment\WorkContextImplementation.cs:line 32   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)   at Orchard.Environment.WorkContextImplementation.FindResolverForState[T](String name) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\Environment\WorkContextImplementation.cs:line 32   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)   at Orchard.Environment.WorkContextImplementation.GetState[T](String name) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\Environment\WorkContextImplementation.cs:line 27   at Orchard.WorkContext.get_CurrentSite() in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\WorkContext.cs:line 25   at Szmyd.Orchard.Modules.Menu.Services.HierarchicalMainMenuNavigationProvider.GetTrie() in c:\Projects\orchard\Modules\Szmyd.Orchard.Modules.Menu\Services\HierarchicalMainMenuNavigationProvider.cs:line 103   at Szmyd.Orchard.Modules.Menu.Services.HierarchicalMainMenuNavigationProvider.GetNavigation(NavigationBuilder builder) in c:\Projects\orchard\Modules\Szmyd.Orchard.Modules.Menu\Services\HierarchicalMainMenuNavigationProvider.cs:line 34   at Orchard.UI.Navigation.NavigationManager.<GetSources>d__c.MoveNext() in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\UI\Navigation\NavigationManager.cs:line 84   at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)   at Orchard.UI.Navigation.NavigationManager.Merge(IEnumerable`1 sources) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\UI\Navigation\NavigationManager.cs:line 94   at Orchard.UI.Navigation.NavigationManager.BuildMenu(String menuName) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\UI\Navigation\NavigationManager.cs:line 24   at Orchard.UI.Navigation.MenuFilter.OnResultExecuting(ResultExecutingContext filterContext) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\UI\Navigation\MenuFilter.cs:line 34   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b()   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)

Coordinator
Mar 23, 2011 at 7:36 PM

Can you try to switch to full trust and see if it makes a difference?

Mar 24, 2011 at 3:56 PM

I put <trust level="Full" originUrl="" /> in my <system.web> section and still get the same error.

Mar 24, 2011 at 4:17 PM

I got it to work.

I was developing my modules and themes using the Orchard.Web.1.0.20 version of the site. When I moved over to the source version Orchard.Source.1.0.20 and changed the trust level to full it worked great. I was under the impression if you were 'building on' you should use the web version if you were modifying the core product you should use the source version. My solution might have had some issues too though cause now I have solution folders and active project files, in the web version they were just normal folders.

Coordinator
Mar 25, 2011 at 1:18 AM

So it's interesting for us to know that the trust level has an impact on this but if you want your module to be usable on partial trust servers, we should try to understand what's going on here. Could you share the code with me so that we have a clear repro?

Oct 13, 2011 at 5:33 PM

I am getting the same problem, using the latest web build (1.3) (not the source code build). Only happens when I try and debug runs fine otherwise. If I try and debug I get the "Operation could destabilize the runtime", and then a 'IIS Express Worker Process has stopped working' message. Changing trust levels hasn't seemed to do anything.

Oct 13, 2011 at 5:36 PM

Stack Trace:

[VerificationException: Operation could destabilize the runtime.]
   Orchard.WarmupStarter.WarmupHttpModule.BeginBeginRequest(Object sender, EventArgs e, AsyncCallback cb, Object extradata) in d:\Builds\OrchardFull\src\Orchard.Startup\WarmupHttpModule.cs:86
   System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +135
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +148
Coordinator
Oct 13, 2011 at 6:05 PM

There must be something going crazy with a specific module. Which ones have you enabled ? Could you try to deactivate them one by one to identify the culprit ?

Oct 14, 2011 at 4:36 PM

Still having the problem have downloaded Orchard.Web.1.3.9.zip, unzipped, open as website in visual studio, try and debug and I get the error. Have tried on a few machines.

Coordinator
Oct 15, 2011 at 7:22 AM

If using Visual Studio, please download the source code release, not the web zip.

Nov 17, 2011 at 10:45 AM

I would also like to use the WebSite Project in Debug from Visual Studio. The WebSite Project is 30Mb. The source version is an eye watering 800Mb. I would really appreciate any feedback from the Orchard team on how to avoid the "Operation could destabilize the runtime" warning using the WebSite Project. It also differs between developer machines. My machine does not show the warning (Visual Studio Ultimate 2010), whilst for other members in my team it does. Any input would be very helpful.

Coordinator
Nov 17, 2011 at 6:40 PM

You can open it in VS as a web site (not a web application project) and use VS as a glorified text editor but you will never be able to build unless you get the full source code. Hard drives are cheap.

Nov 30, 2011 at 8:17 PM

for some reason I get the same "Operation could destabilize the runtime" error when I try to run orchard with Ants Profiler attached. (an older version of Ants, I must admit)

A commenter on my blog also has this problem when trying to attach Eqatec profiler (which works fine on my pc). It sounds like something really nasty, so I skipped Ants altogether and am coping fine with Eqatec as profiler.

If you're interested in reproducing, maybe looking at these two profilers will give a good direction...

Apr 12, 2012 at 7:18 PM

I have also had this problem since installing VS11. I'm running the 1.4.0 source which was fine before. I've experienced this on 2 PC's now, both only since installing VS11...

Source File: D:\Websites\Orchard\src\Orchard.Web\Core\Common\Handlers\CommonPartHandler.cs Line: 0

[VerificationException: Operation could destabilize the runtime.]
   Orchard.Core.Common.Handlers.CommonPartHandler..ctor(IRepository`1 commonRepository, IRepository`1 commonVersionRepository, IClock clock, IAuthenticationService authenticationService, IContentManager contentManager, IContentDefinitionManager contentDefinitionManager) in D:\Websites\Orchard\src\Orchard.Web\Core\Common\Handlers\CommonPartHandler.cs:0

May 15, 2012 at 2:01 PM
GadgetGeek wrote:

I have also had this problem since installing VS11. I'm running the 1.4.0 source which was fine before. I've experienced this on 2 PC's now, both only since installing VS11...

Source File: D:\Websites\Orchard\src\Orchard.Web\Core\Common\Handlers\CommonPartHandler.cs Line: 0

[VerificationException: Operation could destabilize the runtime.]
   Orchard.Core.Common.Handlers.CommonPartHandler..ctor(IRepository`1 commonRepository, IRepository`1 commonVersionRepository, IClock clock, IAuthenticationService authenticationService, IContentManager contentManager, IContentDefinitionManager contentDefinitionManager) in D:\Websites\Orchard\src\Orchard.Web\Core\Common\Handlers\CommonPartHandler.cs:0

Any chance you figured out how to run it after installing VS11? I've got the same exception with the same scenario.

May 15, 2012 at 2:05 PM

Yes, Update to the 1.4.1 release as the issue has now been resolved. If you trawl through the source you will see what the fix was, I can't remember off the top of my head, but it is mentioned in some other threads too.

May 15, 2012 at 4:51 PM

Thanks GadgetGeek.

I found a thread with more detail and a few workarounds if you're unable to update like I was. http://orchard.codeplex.com/discussions/346791

I ended up running it on full blown IIS on my dev machine.