CSLA 4.2.2 Broke"ApplicationContext.User"

CSLA 4.2.2 Broke"ApplicationContext.User"

Old forum URL: forums.lhotka.net/forums/t/11154.aspx

rxelizondo posted on Monday, February 13, 2012


I decided to update from CSLA 4.1.0 to 4.2.2 and was expecting everything to continue to work seamlessly but that wasn't the case.

One thing that I noticed is that the call to "ApplicationContext.User" on version 4.2.2 does not behave the same way as on version 4.1.0.

I searched the change log and didn't find anything regarding breaking changes so I wasn't expecting the change on behavior. I did do a comparison between the two version of the "ApplicationContext" file and notice some significant changes.

Anyway, I don't have time to dig in to see what is going on but I just wanted to bring up the issue. if someone know the reason for the change I would appreciated the feedback if not, I will probably investigate the issue further later on during the week.


RockfordLhotka replied on Monday, February 13, 2012

On what platform?

There were changes to the way the web implementation was loaded to address a bug. I don't think we changed the actual implementation of the web or XAML providers though - just the way in which the web provider is loaded.

rxelizondo replied on Tuesday, February 28, 2012

Hi Rocky,

Sorry for taking so long to get back to you. To answer your question, this is failing on a WPF application.

I haven’t had the chance to go back and try to figure out what exactly is going on but if I recall correctly, the issue occurs as follows:

   1) I set the "ApplicationContext.User" value during application start up.

   2) At some point or another without reason, the CSLA resets the "ApplicationContext.User" to null.

This of course would cause all kinds of issue but the problem for me surfaced when the CSLA was executing one of the IsInRole rules because the IsInRole uses "ApplicationContext.User" internally and since "ApplicationContext.User" is null the application fails to resolve the rule.


JonnyBee replied on Tuesday, February 28, 2012


Please make sure that Csla.Xaml.dll is present and Csla.Web is not present in your bin folder.

The ApplicationContext manager is dynamically loaded based on the presence of either on dll's (types) in this prioritized sequence:

  1. Csla.Web.ApplicationContextManager
  2. Csla.Xaml.ApplicationContextManager
  3. Csla.ApplicationContext.ApplicationContextManager


rxelizondo replied on Tuesday, February 28, 2012


Ok, I guess I could try that but just to be clear, things are working fine on version 4.1, so does this means that the change in behavior is a breaking change introduced on version 4.2?



JonnyBee replied on Tuesday, February 28, 2012

Yes, the "4.1 ApplicationContext"  was moved to Csla.Xaml assembly and the default ApplicationContext stripped of Xaml application code to support Mono with the same codebase.

And the Csla.Xaml ApplicationContext is loaded dynamically similar to Csla.Web.ApplicationContext in Csla 4.1.




rxelizondo replied on Tuesday, February 28, 2012


Just curious, what if I wasn't using XAML at all? What if I was using a Console application or Windows Forms application?

Sorry if this is a silly question but I have not kept up to date with the CSLA.


RockfordLhotka replied on Tuesday, February 28, 2012

I talk about this in the Using CSLA 4 books.

There are three environments we support: WPF, ASP.NET, and 'other'. To support these we use a provider model to load the right implementation. We had to factor this out a bit to support mono, but the code is the same, just in different assemblies.

rxelizondo replied on Friday, March 16, 2012

Ok, adding "Csla.Xaml.dll" appears to have fixed the problem but there was one small issue.   I like to copy the folders containing the CSLA source code into my project (not just the dll) so when adding the "Csla.Xaml" project I got an error telling me that the "Error.png", "Information.png" and "Warning.png" files where not found. The reason is because the "files" are actually shortcuts to real files located on the "Csla.Silverlight" project folder. Given the fact that there are people out there (like me) that could not possible care less about Silverlight, I wish the shortcuts where replaced with the actual files to avoid the issue. It would be a nice thing to do.


Rocky, could you please tell me the Using CSLA 4 book name as well as the title of the section (page number would be great) that describes how the CSLA supports those three models. Specifically, I would like to know what i need to do to remove the dependency on "Csla.Xaml.dll".


RockfordLhotka replied on Friday, March 16, 2012

Thankfully tables of contents are easy to read, and thankfully I put a TOC in each book. The User property topic is listed as an entry right in the TOC, because it is relatively important.

As we're talking about WPF and Silverlight, you can probably imagine that the TOC to look at is in the Using CSLA 4: WPF and Silverlight book. That's where I looked anyway.

And ... drum roll please ... looking at the TOC, the winning page is ... 31.

rxelizondo replied on Saturday, March 17, 2012


Ok, judging from the way you responded to my post (in a sarcastic way) my guess is that I must have rubbed you the wrong way. Being the fact that this wasn’t my intention I will try to redeem myself:

If my comment about "I could not care less about Silverlight" sounded like a mindless rant or implied that I didn’t appreciate the work you have done around Silverlight then I apologize, this wasn’t my intention.

If asking (right down to the page number) the book section that covers the "User" property topic sounds like I am asking for too much then you are obviously correct. The truth is that I had not even downloaded the Using WPF / Silverlight book or even looked into any of the other books when I asked the question and I should probably have put at least a minimum amount of effort looking for an answer.

Again, I apologize, a lot of our focus has now move or is in the process of moving to Linux \ Android platforms so running into technical difficulties revolving around Microsoft based technologies has now turned away from what it used to be an exciting challenge and an opportunity to learn something new  into nothing but frustration. So lately, instead of taking the time to investigate an issue I just immediately jump into posting looking for a quick answer or just to rant about it.

I think I am going through a technology frustration phase, hope it will be over soon.

Thanks for answering the question though!



RockfordLhotka replied on Saturday, March 17, 2012

Sorry, I too am going through a frustrating and challenging period in my life right now, and I am finding it hard to have as much patience as necessary with people's technical frustration as they post on the forum. I really need to just not answer at all, rather than allowing everything else that's going on to spill over into this venue.

rxelizondo replied on Sunday, March 18, 2012


No worries, keep up the good work, I certainly appreciate your efforts and patient... You know, I still remember picking up that Visual Basic 6 Business Objects book oh so many years ago (I think I got it from the Borders bookstore) it was a life changing event for me, you have been an inspiration to many of us and will always be number one in my books!

Hope whatever is frustrating you will soon pass, just hang in there!

Copyright (c) Marimer LLC