Trying to make custom Identity : CslaIdentity

Trying to make custom Identity : CslaIdentity

Old forum URL:

DanB posted on Wednesday, July 21, 2010

I've had a custom identity working for months now, but I'm trying to implement something new and hitting a wall.

I've copied the Roles implementation (backing registration and the property) from CslaIdentity and done nothing but changed Roles to Roles2.

Everything compiles fine, but when I run I get a "type initializer threw an exception" which is apparently happening at the RegisterProperty.  This is identical to what the base class is doing, so what's going on here???


RockfordLhotka replied on Wednesday, July 21, 2010

Is this CSLA 4? If so you'll want to subclass CslaIdentityBase<T> to keep the standard property declarations working.

In 3.8 the type has no generic counterpart (nor does CriteriaBase or CommandBase) and so you can't use the lambda-based property registrations, and you must specify the correct type for the first parameter of the RegisterProperty() calls.

DanB replied on Wednesday, July 21, 2010

It's CSLA 3.8 with SL4.

Not using the lambda registrations.  As I said, I literally copied the Roles implementation from CslaIdentity and changed the names, just to try to get something working.  It compiles fine, but crashes with the initialization error when I run it.

DanB replied on Wednesday, July 21, 2010

OK, I went to the RegisterProperty signature I used in other custom properties and it worked.  That was indeed the problem.

Now it makes me wonder how the Roles property registration from CslaIdentity is working though.

Copyright (c) Marimer LLC