Hi, I am using CSLA for silverlight in a 3 tier scenario, all communication is done throw the WcfPortal. I have a base business class declared like this: public class BaseBussinesObject : BusinessBase where TBussinesObject : BaseBussinesObject witch has some common properties like Id my business classes use this like this: public partial class User : BaseBussinesObject The issue I have is that when I try to access from User properties that are in the base class I get a exception: "The type initializer for 'Business.Bos.BaseBussinesObject`1' threw an exception." What am I missing here ? Thank you,
I'd have to see more complete code to help.
I am not sure if this will solve the problem but I remember a similar situation where the error was due to the static properties not being correctly registered.
I thought that there was code in the CSLA base classes to initialize the static PropertyInfo stuff now? We have experienced the same symptom but did not dig deep to find the cause. We simply adjusted our debuging strategy to solve the problem. I would love to track down and fix the underlying cause but can't seem to find the time these days.
In .NET that's true always.
In SL that's true only if the PropertyInfo<T> fields are declared public - that's due to a private reflection limitation of SL.
But of course the base class generic type and RegisterProperty() calls still have to be done correctly or the registration won't be correct even if it does run.
Hi All,
This is my base class:
public abstract class BaseBussinesObject<TBussinesObject> : BusinessBase<TBussinesObject>
where TBussinesObject : BaseBussinesObject<TBussinesObject>
{
public static PropertyInfo<int> IdProperty = RegisterProperty<int>(x => x.Id);
public int Id
{
get { return GetProperty(IdProperty); }
set { SetProperty(IdProperty, value); }
}
}
And here is a implemenation:
public partial class User : BaseBussinesObject <User>
{
}
Accessing User.Id from the silvelight application throws the exception from the first post.
Hope this makes thinks more clear.
Regards,
You create the object by calling DataPortal.Create() right?
Hi,
I am actually using this to get the entity
public static void Get(EventHandler<DataPortalResult<User>> callback, int id)
{
var dp = new DataPortal<User>();
dp.FetchCompleted += callback;
dp.BeginFetch(new SingleCriteria<User, int>(id));
}
Regards,
Copyright (c) Marimer LLC