Silverlight MethodAccessException /w ObjectAuthorizationRules

Silverlight MethodAccessException /w ObjectAuthorizationRules

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


Jack posted on Friday, February 06, 2009

If I have a blank method in my object I am getting a MethodAccessException from the BusinessBas.IsSavable( ).  I have blank methods from using the templates to generate my objects a month ago.

   at System.Reflection.MethodBase.PerformSecurityCheck(Object obj, RuntimeMethodHandle method, IntPtr parent, UInt32 invocationFlags)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Csla.Security.ObjectAuthorizationRules.GetRoles(Type objectType)
   at Csla.Security.AuthorizationRules.GetAllowEditRoles(Type objectType)
   at Csla.Security.AuthorizationRules.CanEditObject(Type objectType)
   at Csla.Core.BusinessBase.get_IsSavable()

 

In my BO:

private static void AddObjectAuthorizationRules()

{

// TODO: add authorization rules

//AuthorizationRules.AllowEdit(typeof(DataField), "Role");

}

James Thomas replied on Friday, February 06, 2009

I have exactly the same in mine, but don't get exceptions. I haven't upgraded to 3.6.1 yet. Maybe something's changed between versions?

sergeyb replied on Friday, February 06, 2009

AddObjectAuthorizationRules must be public in Silverlight.

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: Jack [mailto:cslanet@lhotka.net]
Sent: Friday, February 06, 2009 5:20 PM
To: Sergey Barskiy
Subject: [CSLA .NET] Silverlight MethodAccessException /w ObjectAuthorizationRules

 

If I have a blank method in my object I am getting a MethodAccessException from the BusinessBas.IsSavable( ).  I have blank methods from using the templates to generate my objects a month ago.

   at System.Reflection.MethodBase.PerformSecurityCheck(Object obj, RuntimeMethodHandle method, IntPtr parent, UInt32 invocationFlags)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Csla.Security.ObjectAuthorizationRules.GetRoles(Type objectType)
   at Csla.Security.AuthorizationRules.GetAllowEditRoles(Type objectType)
   at Csla.Security.AuthorizationRules.CanEditObject(Type objectType)
   at Csla.Core.BusinessBase.get_IsSavable()

 

In my BO:

private static void AddObjectAuthorizationRules()

{

// TODO: add authorization rules

//AuthorizationRules.AllowEdit(typeof(DataField), "Role");

}



Jack replied on Monday, February 09, 2009

Sergey

 

Thanks – Is there a general rule of thumb here? 

 

Jack

 

From: Sergey Barskiy [mailto:cslanet@lhotka.net]
Sent: Friday, February 06, 2009 5:29 PM
To: jaddington@alexandergracie.com
Subject: RE: [CSLA .NET] Silverlight MethodAccessException /w ObjectAuthorizationRules

 

AddObjectAuthorizationRules must be public in Silverlight.

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: Jack [mailto:cslanet@lhotka.net]
Sent: Friday, February 06, 2009 5:20 PM
To: Sergey Barskiy
Subject: [CSLA .NET] Silverlight MethodAccessException /w ObjectAuthorizationRules

 

If I have a blank method in my object I am getting a MethodAccessException from the BusinessBas.IsSavable( ).  I have blank methods from using the templates to generate my objects a month ago.

   at System.Reflection.MethodBase.PerformSecurityCheck(Object obj, RuntimeMethodHandle method, IntPtr parent, UInt32 invocationFlags)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Csla.Security.ObjectAuthorizationRules.GetRoles(Type objectType)
   at Csla.Security.AuthorizationRules.GetAllowEditRoles(Type objectType)
   at Csla.Security.AuthorizationRules.CanEditObject(Type objectType)
   at Csla.Core.BusinessBase.get_IsSavable()

 

In my BO:

private static void AddObjectAuthorizationRules()

{

// TODO: add authorization rules

//AuthorizationRules.AllowEdit(typeof(DataField), "Role");

}

 



sergeyb replied on Monday, February 09, 2009

The issue is that Silverlight’s reflection is limited in the fact that you cannot call private members of a class from outside the class itself.  So, you could have two versions of the method – private for .NET and public for SL, but that seems like an overkill to me, so I personally just have one public method.

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: Jack Addington [mailto:cslanet@lhotka.net]
Sent: Monday, February 09, 2009 8:54 AM
To: Sergey Barskiy
Subject: RE: [CSLA .NET] Silverlight MethodAccessException /w ObjectAuthorizationRules

 

Sergey

 

Thanks – Is there a general rule of thumb here? 

 

Jack

 

From: Sergey Barskiy [mailto:cslanet@lhotka.net]
Sent: Friday, February 06, 2009 5:29 PM
To: jaddington@alexandergracie.com
Subject: RE: [CSLA .NET] Silverlight MethodAccessException /w ObjectAuthorizationRules

 

AddObjectAuthorizationRules must be public in Silverlight.

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: Jack [mailto:cslanet@lhotka.net]
Sent: Friday, February 06, 2009 5:20 PM
To: Sergey Barskiy
Subject: [CSLA .NET] Silverlight MethodAccessException /w ObjectAuthorizationRules

 

If I have a blank method in my object I am getting a MethodAccessException from the BusinessBas.IsSavable( ).  I have blank methods from using the templates to generate my objects a month ago.

   at System.Reflection.MethodBase.PerformSecurityCheck(Object obj, RuntimeMethodHandle method, IntPtr parent, UInt32 invocationFlags)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Csla.Security.ObjectAuthorizationRules.GetRoles(Type objectType)
   at Csla.Security.AuthorizationRules.GetAllowEditRoles(Type objectType)
   at Csla.Security.AuthorizationRules.CanEditObject(Type objectType)
   at Csla.Core.BusinessBase.get_IsSavable()

 

In my BO:

private static void AddObjectAuthorizationRules()

{

// TODO: add authorization rules

//AuthorizationRules.AllowEdit(typeof(DataField), "Role");

}

 

 



Jack replied on Monday, February 09, 2009

That is what I thought.  So basically any internal CSLA methods that could be called by the framework should really be public.

 

Is there any way to implement a set of compiler warnings that would pick up on that stuff?  Or just experience / trial & error?

 

From: Sergey Barskiy [mailto:cslanet@lhotka.net]
Sent: Monday, February 09, 2009 7:06 AM
To: jaddington@alexandergracie.com
Subject: RE: [CSLA .NET] Silverlight MethodAccessException /w ObjectAuthorizationRules

 

The issue is that Silverlight’s reflection is limited in the fact that you cannot call private members of a class from outside the class itself.  So, you could have two versions of the method – private for .NET and public for SL, but that seems like an overkill to me, so I personally just have one public method.

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: Jack Addington [mailto:cslanet@lhotka.net]
Sent: Monday, February 09, 2009 8:54 AM
To: Sergey Barskiy
Subject: RE: [CSLA .NET] Silverlight MethodAccessException /w ObjectAuthorizationRules

 

Sergey

 

Thanks – Is there a general rule of thumb here? 

 

Jack

 

From: Sergey Barskiy [mailto:cslanet@lhotka.net]
Sent: Friday, February 06, 2009 5:29 PM
To: jaddington@alexandergracie.com
Subject: RE: [CSLA .NET] Silverlight MethodAccessException /w ObjectAuthorizationRules

 

AddObjectAuthorizationRules must be public in Silverlight.

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: Jack [mailto:cslanet@lhotka.net]
Sent: Friday, February 06, 2009 5:20 PM
To: Sergey Barskiy
Subject: [CSLA .NET] Silverlight MethodAccessException /w ObjectAuthorizationRules

 

If I have a blank method in my object I am getting a MethodAccessException from the BusinessBas.IsSavable( ).  I have blank methods from using the templates to generate my objects a month ago.

   at System.Reflection.MethodBase.PerformSecurityCheck(Object obj, RuntimeMethodHandle method, IntPtr parent, UInt32 invocationFlags)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Csla.Security.ObjectAuthorizationRules.GetRoles(Type objectType)
   at Csla.Security.AuthorizationRules.GetAllowEditRoles(Type objectType)
   at Csla.Security.AuthorizationRules.CanEditObject(Type objectType)
   at Csla.Core.BusinessBase.get_IsSavable()

 

In my BO:

private static void AddObjectAuthorizationRules()

{

// TODO: add authorization rules

//AuthorizationRules.AllowEdit(typeof(DataField), "Role");

}

 

 

 



sergeyb replied on Monday, February 09, 2009

Not that I am aware of.

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: Jack Addington [mailto:cslanet@lhotka.net]
Sent: Monday, February 09, 2009 9:19 AM
To: Sergey Barskiy
Subject: RE: [CSLA .NET] Silverlight MethodAccessException /w ObjectAuthorizationRules

 

That is what I thought.  So basically any internal CSLA methods that could be called by the framework should really be public.

 

Is there any way to implement a set of compiler warnings that would pick up on that stuff?  Or just experience / trial & error?

 

From: Sergey Barskiy [mailto:cslanet@lhotka.net]
Sent: Monday, February 09, 2009 7:06 AM
To: jaddington@alexandergracie.com
Subject: RE: [CSLA .NET] Silverlight MethodAccessException /w ObjectAuthorizationRules

 

The issue is that Silverlight’s reflection is limited in the fact that you cannot call private members of a class from outside the class itself.  So, you could have two versions of the method – private for .NET and public for SL, but that seems like an overkill to me, so I personally just have one public method.

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: Jack Addington [mailto:cslanet@lhotka.net]
Sent: Monday, February 09, 2009 8:54 AM
To: Sergey Barskiy
Subject: RE: [CSLA .NET] Silverlight MethodAccessException /w ObjectAuthorizationRules

 

Sergey

 

Thanks – Is there a general rule of thumb here? 

 

Jack

 

From: Sergey Barskiy [mailto:cslanet@lhotka.net]
Sent: Friday, February 06, 2009 5:29 PM
To: jaddington@alexandergracie.com
Subject: RE: [CSLA .NET] Silverlight MethodAccessException /w ObjectAuthorizationRules

 

AddObjectAuthorizationRules must be public in Silverlight.

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: Jack [mailto:cslanet@lhotka.net]
Sent: Friday, February 06, 2009 5:20 PM
To: Sergey Barskiy
Subject: [CSLA .NET] Silverlight MethodAccessException /w ObjectAuthorizationRules

 

If I have a blank method in my object I am getting a MethodAccessException from the BusinessBas.IsSavable( ).  I have blank methods from using the templates to generate my objects a month ago.

   at System.Reflection.MethodBase.PerformSecurityCheck(Object obj, RuntimeMethodHandle method, IntPtr parent, UInt32 invocationFlags)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Csla.Security.ObjectAuthorizationRules.GetRoles(Type objectType)
   at Csla.Security.AuthorizationRules.GetAllowEditRoles(Type objectType)
   at Csla.Security.AuthorizationRules.CanEditObject(Type objectType)
   at Csla.Core.BusinessBase.get_IsSavable()

 

In my BO:

private static void AddObjectAuthorizationRules()

{

// TODO: add authorization rules

//AuthorizationRules.AllowEdit(typeof(DataField), "Role");

}

 

 

 

 



Copyright (c) Marimer LLC