Inheritance CSLA BO in WCF

I created an inherited CSLA BO, it worked OK until I moved it into WCF, the probolem is:

Index was outside of the bounds of array.

It people are having similar problem in forum, here and here. Rocky’s solution is adding a dummy static field ( or constructor ) in base BO.

But this doesn’t work for my WCF. In fact, I don’t even have this problem in my non-WCF mode app.

Still the static propertyInfo field problem, I later found another trick similar to Rocky’s dummy field one.

Calling the private constructor right before DataPortal mehod.

Example, my OrganizationBO is inherited from a base StakeholderBO, so the revised factory method looks like this:

public static OrganizationBO GetOrganizationBO(int stakeholderId)
// Had to add this line to make it work in WCF mode.
// Why? 2008.06.25
// Might be to force static register field run earlier.
new OrganizationBO();

return DataPortal.Fetch<OrganizationBO>(new SingleCriteria<OrganizationBO, int>(stakeholderId));

P.S.,  This post is very helpful when you got maxReceivedMessageSize in WCF configuration.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s