CSLA and the watch window

One of my biggest complaints about using CSLA has been the issue of Visual Studio’s failure to work correctly in the watch window with CSLA objects. 

I wrote a post a while back about my issues:

So for example I have a simple list called “projects” which is of type ProjectList containing ProjectListItems.

If I put “projects” in the watch window, for Value I get:

“Count = {System.TypeLoadException}”

If I put “projects(0)” in the watch window, I get:

{“The generic type ‘System.Collections.ObjectModel.Collection`1’ was used with the wrong number of generic arguments in assembly ‘mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089’.” : “System.Collections.ObjectModel.Collection`1”}

Rocky’s response was:

This is a known issue. I’ve actually talked to the VS debugger team about this, and they didn’t have a satisfactory answer – and certainly not a solution. This issue has existed since 2005 when generics were introduced into .NET.

Well, after doing some digging I think I have come across a few work arounds.

If I were to use the Watch Window and put:


it would throw an error.  But if I put:


then I get the correct result.

Also when picking a specific item:


I get the same exception.  However, if I use:


I get the object as expected!

I hope this helps out others as this is really important when debugging an application.



Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s