Hello,
I am a beginer user of CSLA. I am reading
Rockford Lhotka
Apress®
© 2004 Rockford Lhotka
I complete the CSLA frame work and Project Tracker from this book.
When I try to create a new instance of Project class I received the following Error.
I compare my code with one on the Web site its look like same.
Line 77: return Activator.CreateInstance(businessType, true);
StackOverflowException: Exception of type System.StackOverflowException was thrown.]
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly) +0
System.Activator.CreateInstance(Type type, Boolean nonPublic) +66
CSLA.Server.DataPortal.CreateBusinessObject(Object criteria) in d:\myprojects\visual studio projects\csla\csla.server.dataportal\dataportal.cs:77
CSLA.Server.DataPortal.Create(Object criteria, Object principal) in d:\myprojects\visual studio projects\csla\csla.server.dataportal\dataportal.cs:142
CSLA.DataPortal.Create(Object criteria) in d:\myprojects\visual studio projects\csla\csla\dataportal.cs:137
ProjectTracker.Library.Project.NewProject() in d:\myprojects\visual studio projects\projecttracker\projecttracker.library\project.cs:205
PTWeb.Projects.btnNewProject_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\ptweb\projects.aspx.cs:81
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +108
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +138
System.Web.UI.Page.ProcessRequestMain() +1244
If any one can shed some light on it.
Thanks,
Aqal
According to book I don't have any thing in constructor below is the code
#region Constructor
private Project()
{
// To prevent direst instantiation
}
#endregion
and below is the static method...
#region Static Methods
public static Project NewProject()
{
if(!Thread.CurrentPrincipal.IsInRole("ProjectManager"))
{
throw new System.Security.SecurityException("User not authorized to add project");
}
return (Project)DataPortal.Create(new Criteria(Guid.Empty));
}
Best,
Aqal
Then all you can do is use the debugger to walk through the code
to see where it goes. A stack overflow is always due to something spinning and
eating up stack memory. It is almost always due to accidental recursion.
Rocky
Copyright (c) Marimer LLC