Exception of type System.StackOverflowException was thrown

Exception of type System.StackOverflowException was thrown

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


Aqalmal posted on Friday, August 31, 2007

Hello,

I am a beginer user of CSLA. I am reading

Expert C# Business Objects

Rockford Lhotka

Apress®

If any one can shed some light on it.

 

Thanks,

Aqal

 

RockfordLhotka replied on Saturday, September 01, 2007

What code do you have in your object's constructor? To get a stack overflow, you almost certainly have a recursive call, and since this happens in the Activator.CreateInstance() call, the only thing .NET will be executing is your constructor.

Aqalmal replied on Sunday, September 02, 2007

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

 

 

RockfordLhotka replied on Monday, September 03, 2007

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