Resolution is not frozen, it is not yet possible to get values from it.
I have a class which inherits from ApplicationEventHandler.
When I remove this inheritance and comment out the two methods (ApplicationStarting and ApplicationStarted overrides) everything is fine, but as soon I put this back in I get the error.
Stack trace:
InvalidOperationException: Resolution is not frozen, it is not yet possible to get values from it.]
Umbraco.Core.ObjectResolution.SingleObjectResolverBase2.get_Value() +410
Umbraco.Core.Services.ServiceContext.<.ctor>b__26() +27
System.Lazy1.CreateValue() +455
Umbraco.Core.Services.<>cDisplayClass3c.2b() +189
System.Lazy1.CreateValue() +14276544
System.Lazy1.LazyInitValue() +476
umbraco.BusinessLogic.User.GetUser(Int32 id) +42
Vega.USiteBuilder.Util.GetAdminUser() +31
[TypeInitializationException: The type initializer for 'Vega.USiteBuilder.Util' threw an exception.]
Vega.USiteBuilder.Util.GetCurrentUmbracoVersion() +24
Vega.USiteBuilder.UmbracoManager.SynchronizeIfNotSynchronized() +126
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165
It sounds like something is happening in your Starting event handler which is trying to access the user service. Have you tried moving your "starting" code to the "started" event handler as within the started event handler, resolution should be frozen and the user service should be available.
But your reply made me think... There are a number of classes in the solution which inherited ApplicationEventHandler so I checked all of those too.
At the moment, my newest class which (I think) is causing the issue, has both the Started and Starting event handlers commented out but even with that being the case, if the class inherits from ApplicationEventHandler, this issue is still present.
As for the other classes, they're all using the Started event with the exception of the ditto factory class which uses Starting.
The newest class is where the problem started though so I assume it's that.
To reiterate, in case this has now become confusing:
I have a number of classes inheriting from ApplicationEventHandler, all of which are using the ApplicationStarted event, not Starting
The newest class currently has the ApplicationEventHandler class named and the two event methods commented out and the issue is still happening
Even more strangely now, when I take the ApplicationEventHandler out and comment out the event method(s) I am now getting redirected to an upgrade URL and it's sticking on that.
Is it a case that the user service hasn't started following from Matts statement. Maybe you need to put a check in before you request anything from it.?
I was away last night by the time I got your responses.
What I've tried this morning:
Since the class I was doing this in has the event handler and therefore ApplicationContext passed as a parameter, AND a separate context for another method, I wondered if things were getting confused by having two contexts available (I've seen this issue in plain MVC apps before). So I moved one method out into a separate class.
I think the stack trace was incorrect as you guys have been talking about user service but this code in particular is using the MediaService so I put a check in
Neither of these things have fixed the issue, but I am back to getting errors related to Examine instead of the Resolution frozen error.
I'm not sure if its the same issue bubbling up in different ways or 2 separate issues.
Resolution frozen....
Hi all,
I'm getting the error
I have a class which inherits from ApplicationEventHandler. When I remove this inheritance and comment out the two methods (ApplicationStarting and ApplicationStarted overrides) everything is fine, but as soon I put this back in I get the error.
Stack trace:
[TypeInitializationException: The type initializer for 'Vega.USiteBuilder.Util' threw an exception.] Vega.USiteBuilder.Util.GetCurrentUmbracoVersion() +24 Vega.USiteBuilder.UmbracoManager.SynchronizeIfNotSynchronized() +126 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165
Any help will be greatly appreciated!
Does your Global.asax inherit from UmbracoApplication? If not I believe that can cause this error some times.
Deevny!
I don't see a global.asax file but that said, there's a few classes in the solution which inherit from ApplicationEventHandler without issue.
This was initially manifesting itself as an examine issue but now this so I'm really baffled as to where the actual issue is
Hey Rich,
It sounds like something is happening in your Starting event handler which is trying to access the user service. Have you tried moving your "starting" code to the "started" event handler as within the started event handler, resolution should be frozen and the user service should be available.
Matt
Hey Matt,
Thanks for the response.
No dice unfortunately.
But your reply made me think... There are a number of classes in the solution which inherited ApplicationEventHandler so I checked all of those too.
At the moment, my newest class which (I think) is causing the issue, has both the Started and Starting event handlers commented out but even with that being the case, if the class inherits from ApplicationEventHandler, this issue is still present.
As for the other classes, they're all using the Started event with the exception of the ditto factory class which uses Starting.
The newest class is where the problem started though so I assume it's that.
To reiterate, in case this has now become confusing:
I'm thoroughly confused! (though that's easily done :D )
Even more strangely now, when I take the ApplicationEventHandler out and comment out the event method(s) I am now getting redirected to an upgrade URL and it's sticking on that.
Arrrgh!!!
Is it a case that the user service hasn't started following from Matts statement. Maybe you need to put a check in before you request anything from it.?
Hey guys,
I was away last night by the time I got your responses. What I've tried this morning:
I think the stack trace was incorrect as you guys have been talking about user service but this code in particular is using the MediaService so I put a check in
if(ApplicationContext.Current.Services.MediaService != null) MediaService.Saving += MediaServiceSaving;
Neither of these things have fixed the issue, but I am back to getting errors related to Examine instead of the Resolution frozen error. I'm not sure if its the same issue bubbling up in different ways or 2 separate issues.
I will appreciate any more ideas you guys have.
R
Update:
Now that I'm able to debug (wasn't able to before) I can see that it's the MediaService in this code which is throwing an exception.
Final update.
I removed the ApplicationContext instance that I was newing up and used the instance which is passed into the event handler and that's fixed it.
So it looks like the application was getting confused with multiple contexts OR that the context I was newing up wasn't running properly.
Thanks to all you guys for the help :)
is working on a reply...