Migrate project from CSLA 3.7 to CSLA 4.0 (how to)

We’ve recently managed to migrate all our product lines from CSLA 3.7 to CSLA 4.0 and here are problem/solutions scenarios.
  • Problem:
    Class contains backend field, but is not registered
    If you don’t do it, exception Csla.PropertyLoadException will be raised with message
  • Property load or set failed for property MyField  (Properties with private backing fields must be marked as  RelationshipTypes.PrivateField)
Solution:
Register backend field:
private int _my_field;
private static readonly PropertyInfo<int> MyFieldProperty = RegisterProperty<int>(o => o.MyField, "My field", RelationshipTypes.PrivateField);
public int MyField
{
       get { return GetProperty(MyFieldProperty, _my_field); }
       set { SetProperty(MyFieldProperty, ref _my_field, value); }
}
Problem:
Method LoadProperty was used like this:
<p>LoadProperty(MyFieldProperty, 10);</p>
exception Csla.PropertyLoadException will be raised with message “Csla.PropertyLoadException: Property load or set failed for property MyField (Attempt to read/load private field property in managed properties.) —> System.InvalidOperationException: Attempt to read/load private field property in managed properties”
In this case, you have to initialize backend field :
_my_field = 10;
  • Problem :
Class contains readonly field ,
private readonly int _my_field;
and you try to set the value using binding, runtime exception raised with message:
“Expression must be writeable Parameter name: left”“Expression must be writeable Parameter name: left”
Solution:
Solution:

Make field static

private static readonly int _my_field;
  • Problem:
Class is inherited from base class :

[Serializable]
public class MyBaseClass<T> : BusinessBase<T> where T : MyBaseClass<T>
{
}

[Serializable]
public class MyConcreteClass : MyBaseClass<MyConcreteClass>
{
   protected static PropertyInfo<string> ConcretePropProperty = RegisterProperty(typeof(MyConcreteClass), new PropertyInfo<string>("ConcretePropProperty"));
   public string ConcreteProp
   {
      get { return GetProperty(ConcretePropProperty); }
      set { SetProperty(ConcretePropProperty, value); }
    }
}

and if properties in MyBaseClass are not registered exception raised with message:

The type initializer for ‘MyConcreteClass’ threw an exception.System.TypeInitializationException: The type initializer for ‘ MyConcreteClass’ threw an exception. —> System.InvalidOperationException: Cannot register property ConcretePropr after containing type (MyBaseClass) has been instantiated
Solution:
You have to register every property in concrete class.
  • Problem:

    Class is inherited from BusinessListBase or BusinessBindingListBase. Adding new items in collection cannot be done.

Solution:
All items that will be added to collection must be created like child.
Did you have issues and would you like to share with community ?

Tags: , , ,

CSLA 4, with support for .NET 4, Silverlight 4 and Visual Studio 2010 – released.

 

This is a major release of the CSLA .NET framework because of significant changes to CSLA itself based on feedback and input from the vibrant CSLA community.

You can download CSLA 4 here.

If this is you first contact with CSLA framework, you can read my previous post introduction to CSLA.

The system cannot find the file specified – The server encountered an unexpected error and stopped. (FIM 2010) – solved.

When I was installing SharePoint 2010 i encounter an error from the title.
Log in EventLog was:

The server encountered an unexpected error and stopped.
“ERR: MMS(4828): libutils.cpp(10475): RegQueryValueEx of Server failed with 2
BAIL: MMS(4828): libutils.cpp(10477): 0×80070002 (The system cannot find the file specified.)
ERR: MMS(4828): libutils.cpp(10475): RegQueryValueEx of SQLInstance failed with 2
BAIL: MMS(4828): libutils.cpp(10477): 0×80070002 (The system cannot find the file specified.)
ERR: MMS(4828): libutils.cpp(10475): RegQueryValueEx of DBName failed with 2
BAIL: MMS(4828): libutils.cpp(10477): 0×80070002 (The system cannot find the file specified.)
BAIL: MMS(4828): server.cpp(281): 0×80070002 (The system cannot find the file specified.)
BAIL: MMS(4828): server.cpp(3518): 0×80070002 (The system cannot find the file specified.)
BAIL: MMS(4828): service.cpp(1528): 0×80070002 (The system cannot find the file specified.)

I spend hours trying to figure out what file missing. Well, solutions was quite different.

I added service account (account for window services Forefront Identity Manager Service  and Forefront Identity Manger Synchronization Service) into three groups on local machine:
 
 FIMSyncOperator, FIMSyncJoiners and FIMSyncBrowse  and errors gone.

Strange was also that when I installed SharePoint 2010, service account was /.
I change this to domain user account and that user added into three groups mention previously.

I hope that this will help someone and save time.

Tags:

ASP .NET MVC – Where to start ?

Video material on ASP .NET MVC is good place to start.
I put links here for easy to find.

ASP .NET MVC 3.0 (Video)

Sample applications:

Did I missed some great link ?

Tags: ,

CSLA 4.0 Preview 4 available

CSLA framework 4.0 preview 4 available for download.

New framework 4.0 in general have break changes (here are some of them):
  – the new business and validation rules subsystem (this is covered in this post and here)
  – removed non-generic DataPortal methods.
  – CommandBase now implements IClonable, which means it works with automatic cloning when using a local data portal deployment. 
More on break changes you can read at Lhotka version 4.0.0 change log.
For highlights on CSLA 4 you can read here.