Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > BOOK: Professional C# 2005
|
BOOK: Professional C# 2005
This is the forum to discuss the Wrox book Professional C# 2005 by Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner, Allen Jones; ISBN: 9780764575341
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 28th, 2007, 10:15 PM
Registered User
 
Join Date: Oct 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Appemdix A - StackOverflowException

Hello

I wrote the following code:

using System;

namespace Wrox.ProCSharp.OOProg
{
    class MainEntryPoint
    {
        static void Main()
        {
            Authenticator myAccess = new Authenticator();
            bool done;
            done = myAccess.ChangePassword("", "MyNewPassword");
            if (done == true)
                Console.WriteLine("Password for myAccess changed");
            else
                Console.WriteLine("Failed to change password for myAccess");
            done = myAccess.ChangePassword("", "AnotherPassword");
            if (done == true)
                Console.WriteLine("Password for myAccess changed");
            else
                Console.WriteLine("Failed to change password for myAccess");

            if (myAccess.IsPasswordCorrect("WhatPassword"))
                Console.WriteLine("Verified myAccess\' password");
            else
                Console.WriteLine("Failed to verify myAccess\' password");
            uint minimo = Authenticator.minPasswordLength;
            Console.WriteLine("Changed!");
        }

    }

    public class Authenticator
    {
        // implementation as shown earlier

        private string password = "";
        //private static uint minPasswordLength = 6;
        public static uint minPasswordLength
        {
            get
            {
                return minPasswordLength;
            }
            set
            {
                minPasswordLength = value;
            }
        }
        /*public static uint GetMinPasswordLength()
        {
            return minPasswordLength;
        }*/

        public bool IsPasswordCorrect(string tryPassword)
        {
            return (tryPassword == password) ? true : false;
        }

        public bool ChangePassword(string oldPassword, string newPassword)
        {
            if (oldPassword == password)
            {
                password = newPassword;
                return true;
            }
            else
                return false;
        }
    }
}

But when I run the program, see the following error:

 public static uint minPasswordLength
 {
  get
  {
   return minPasswordLength;
  }
  set
  {
   minPasswordLength = value;
  }
 }


"An unhandled exception of type 'System.StackOverflowException' occurred in ConsoleApplication7.exe"

How can I solve this problem?
 
Old October 28th, 2007, 11:02 PM
Registered User
 
Join Date: Oct 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

:D i solved the problem:


There was a problem with upercase and lowercase

in the code

Authenticator.MinPasswordLength = 7;

in the class:

        private static uint minPasswordLength = 6;
        public static uint MinPasswordLength
        {
            get
            {
                return minPasswordLength;
            }
            set
            {
                minPasswordLength = value;
            }

sory :(





Similar Threads
Thread Thread Starter Forum Replies Last Post
system.stackoverflowexception in system.windows.fo scheidel21 Pro VB.NET 2002/2003 2 May 18th, 2007 12:40 AM
How to solve System.StackOverFlowException sibajibasak General .NET 3 February 11th, 2005 12:36 AM
StackOverFlowException Problem chiefouko VS.NET 2002/2003 1 July 20th, 2004 03:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.