mAuthorizationRules is nothing after deserialization

mAuthorizationRules is nothing after deserialization

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


Henrik posted on Monday, October 02, 2006

I’m confused. In my web-app I have a simple ReadOnlyBase object holding info about a customer, that I need on every request. Therefore I stuff it into session state.

However, when I retrieve it from session state it doesn’t seem to deserialize authorization rules correctly (or at all).

 

I debugged my way to where the exception is thrown. It is on the first call to a CanReadProperty(<propname>, True), which eventually calls the

 

AuthorizationRules.HasReadAllowedRoles(propertyName)

 

line 264 of ReadOnlyBase in the VB version of the framework, which now returns nothing.

 

Then I had a look at the Core.BusinessBase and saw that it had an OnDeserializedHandler which sets up authorization rules. ReadOnlyBase doesn’t have such a handler. Shouldn’t it have one also, to set up authorization rules?

 

Anyway, I added an OnDeserializedHandler to ReadOnlyBase and had it call the AddAuthorizationRules but to no avail. The mAuthorizationRules is still nothing.

 

I’ve searched through the forum and think it relates to the problems described in this thread:

http://forums.lhotka.net/forums/thread/5398.aspx

 

and it looks like the Dictionary(Of TKey, TValue) is the culprit, by not deserializing properly (or maybe doesn’t serialize it's values at all).

 

I’m really lost on this issue. Have any of you guys stumbled upon this and found a solution.

 

/Henrik

Henrik replied on Monday, October 02, 2006

Just wanted to add to my first post.

Another thing that wonders me is that the member that holds authorization rules in ReadOnlyBase i different from that in Core.BusinessBase. It's decalared like this:

<NotUndoable()> _
<NonSerialized()> _
Private mAuthorizationRules As New Security.AuthorizationRules(Me.GetType)

and the property that returns it i declared as

Protected ReadOnly Property AuthorizationRules()  As Security.AuthorizationRules
 
Get
   
Return mAuthorizationRules
 
End Get
End Property

where in Core.BusinessBase it isn't instantiated in the member declaration but in the property like this:

Protected ReadOnly Property AuthorizationRules()  As Security.AuthorizationRules
 
Get
   
If mAuthorizationRules Is Nothing Then
     
mAuthorizationRules = New Security.AuthorizationRules(Me.GetType)
   
End If
   
Return mAuthorizationRules
 
End Get
End Property

I have changed the readonly base to do the same thing as Core.BusinessBase and now everything works fine.

Rocky, is this a bug in ReadOnlyBase or am I missing something?

/Henrik

RockfordLhotka replied on Tuesday, October 03, 2006

It sounds like a bug - is this in 2.0 or 2.1?

Henrik replied on Tuesday, October 03, 2006

Hi Rocky

It's in v2.1 RC1, but I just checked the 2.1 RTM and it has the same issues.

 

RockfordLhotka replied on Tuesday, October 03, 2006

Henrik:

Hi Rocky

It's in v2.1 RC1, but I just checked the 2.1 RTM and it has the same issues.



OK, I have updated the RTM with the fix to this issue - please download the current file and see if it solves your issue - thanks for finding this.

Henrik replied on Tuesday, October 03, 2006

Yep, now it works perfectly.

Sorry for not catching this before the RTM.

Cheers

/Henrik

Copyright (c) Marimer LLC