Can't get Silverlight Rolodex sample to work - 3.6.1

Can't get Silverlight Rolodex sample to work - 3.6.1

Old forum URL: forums.lhotka.net/forums/t/6373.aspx


cds posted on Sunday, February 08, 2009

I've downloaded the 3.6.1 version of the Cslalight Rolodex sample (C# version) and tried to get it to work but without success. I've had the SimpleApp sample working...

I've seen other posts on the forum where people have run into trouble - but I think I've covered all the obvious things.

I have 3.6.1 of CSLA downloaded and I've built the solutions for CSLA and CslaLight. I have the following project references:

I've updated the connection string to point to the physical locaiton of the database (on my H:\ drive).

Then, I set Web as the startup project, and Default.aspx as the start page.

I then run and the Silverlight page comes up, and I enter Admin/admin as the username/password. I get Invalid login. Try again.

I don't think it's going anywhere near the server. I put a breakpoint in the Rolodex.Identity class on GetIdentity, and DataPortal_Fetch methods (and I use Debug -> Attach to process to connect to the WCF Host process - the breakpoints then come alive - i.e. turn into full red dots) and try to logon, but it doesn't get anywhere near that code.

So, now I try adding the CSLA and CslaLight projects to my solution and updating the references. That way, I can put breakpoints directly in the CSLA code and see what's going on. Then I rebuild and run again, reattaching the debugger to the WCF Host process.

This time, after much debugging, I put a breakpoint in the SimpleDataPortal's Fetch Method. This is the DataPortal that seems to be being utilized. I can break in there, and get to the line:

obj = new LateBoundObject(objectType);

whereupon it throws an exception:

base {System.SystemException} = {"The type initializer for 'Rolodex.Business.Security.RolodexIdentity' threw an exception."}

with the inner exception:

Message = "Can not register property UserId after containing type has been instantiated"

   at Rolodex.Business.Security.RolodexIdentity..ctor()
   at ctor()
   at Csla.Reflection.MethodCaller.CreateInstance(Type objectType) in H:\CSLA.NET\cslacs\Csla\Reflection\MethodCaller.cs:line 103
   at Csla.Reflection.LateBoundObject..ctor(Type objectType) in H:\CSLA.NET\cslacs\Csla\Reflection\LateBoundObject.cs:line 29
   at Csla.Server.SimpleDataPortal.Fetch(Type objectType, Object criteria, DataPortalContext context) in H:\CSLA.NET\cslacs\Csla\Server\SimpleDataPortal.cs:line 106

 

Now, this makes me suspect that there's something wrong in the configuration and that it's not using the remote data portal but somehow using the local one and that the business object is already initialised.  Or am I off track here. (When I look at the DataPortalContext object, its IsRemotePortal property is false.) 

Anyway, can somebody point me in the right direction for this please. I'm hoping to get this going sometime soon!

Thanks,

Craig

 

 

 

 

 

 

sergeyb replied on Monday, February 09, 2009

There is an issue with Rolodex sample that was recently uncovered.  You need to update RolodexIdentity to have type in RegisterProperty line, as in:

 

RegisterProperty(typeof(RolodexIdentity), new ProeprtyInfo…)

 

I think I already replied to a similar issue a few days ago.

 

Thanks.

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: cds [mailto:cslanet@lhotka.net]
Sent: Sunday, February 08, 2009 11:02 PM
To: Sergey Barskiy
Subject: [CSLA .NET] Can't get Silverlight Rolodex sample to work - 3.6.1

 

I've downloaded the 3.6.1 version of the Cslalight Rolodex sample (C# version) and tried to get it to work but without success. I've had the SimpleApp sample working...

I've seen other posts on the forum where people have run into trouble - but I think I've covered all the obvious things.

I have 3.6.1 of CSLA downloaded and I've built the solutions for CSLA and CslaLight. I have the following project references:

I've updated the connection string to point to the physical locaiton of the database (on my H:\ drive).

Then, I set Web as the startup project, and Default.aspx as the start page.

I then run and the Silverlight page comes up, and I enter Admin/admin as the username/password. I get Invalid login. Try again.

I don't think it's going anywhere near the server. I put a breakpoint in the Rolodex.Identity class on GetIdentity, and DataPortal_Fetch methods (and I use Debug -> Attach to process to connect to the WCF Host process - the breakpoints then come alive - i.e. turn into full red dots) and try to logon, but it doesn't get anywhere near that code.

So, now I try adding the CSLA and CslaLight projects to my solution and updating the references. That way, I can put breakpoints directly in the CSLA code and see what's going on. Then I rebuild and run again, reattaching the debugger to the WCF Host process.

This time, after much debugging, I put a breakpoint in the SimpleDataPortal's Fetch Method. This is the DataPortal that seems to be being utilized. I can break in there, and get to the line:

obj = new LateBoundObject(objectType);

whereupon it throws an exception:

base {System.SystemException} = {"The type initializer for 'Rolodex.Business.Security.RolodexIdentity' threw an exception."}

with the inner exception:

Message = "Can not register property UserId after containing type has been instantiated"

   at Rolodex.Business.Security.RolodexIdentity..ctor()
   at ctor()
   at Csla.Reflection.MethodCaller.CreateInstance(Type objectType) in H:\CSLA.NET\cslacs\Csla\Reflection\MethodCaller.cs:line 103
   at Csla.Reflection.LateBoundObject..ctor(Type objectType) in H:\CSLA.NET\cslacs\Csla\Reflection\LateBoundObject.cs:line 29
   at Csla.Server.SimpleDataPortal.Fetch(Type objectType, Object criteria, DataPortalContext context) in H:\CSLA.NET\cslacs\Csla\Server\SimpleDataPortal.cs:line 106

 

Now, this makes me suspect that there's something wrong in the configuration and that it's not using the remote data portal but somehow using the local one and that the business object is already initialised.  Or am I off track here. (When I look at the DataPortalContext object, its IsRemotePortal property is false.) 

Anyway, can somebody point me in the right direction for this please. I'm hoping to get this going sometime soon!

Thanks,

Craig

 

 

 

 

 

 



cds replied on Monday, February 09, 2009

Hi Sergey

Thanks, that did work. You were referring to this thread: http://forums.lhotka.net/forums/thread/30823.aspx

In order to help others, the RolodexIdentity class needs to have the UserIdProperty static initializer code changed to read:

private static readonly PropertyInfo<int> UserIdProperty =

RegisterProperty<int>(typeof (RolodexIdentity), new PropertyInfo<int>("UserId", "User Id", 0));

And it would be good if the sample could be updated so others don't download the incorrect code.

Additionally, the error message could have been more helpful if it said:

Can not register property UserId after containing type (CslaIdentity) has been instantiated

I.e. add the name of the type the property is being registered on to the message - that would have made the problem clearer for me.

Anyway, thanks for the help. I did learn quite a bit along the way by delving into the CSLA code.

Craig

chrduf replied on Wednesday, February 18, 2009

In VB.NET the RolodexIdentity class needs to have the UserID property static initializer code changed to:

        Private Shared UserIdProperty As PropertyInfo(Of Integer) = _
            RegisterProperty(Of Integer)(GetType(RolodexIdentity), New PropertyInfo(Of Integer)("UserId", "User Id", 0))

Copyright (c) Marimer LLC