Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 2nd, 2012, 08:10 AM
Authorized User
Points: 170, Level: 3
Points: 170, Level: 3 Points: 170, Level: 3 Points: 170, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 43
Thanks: 11
Thanked 0 Times in 0 Posts
Default Chapter 19 page 702

Hi, I have finished the chapter but had to go back to the first exercise of this chapter because of an error I cant seem to shake off,

In the exercise on page 702 it instructs you to insert the following code:
Code:
    public static string FromAddress
    {
        get
        {
            string result = WebConfigurationManager.AppSettings.Get("FromAddress");
            if (!string.IsNullOrEmpty(result))
            {
                return result;
            }
        }
        throw new Exception("AppSettings FromAddress not found in web.config file.");
    }
But I am getting errors for both "get" and "throw". For "get" it says 'AppConfiguration.FromAddress.get': not all code paths return a value and for "throw" it says "a get or set accessor expected".

I have inserted the using.System.Web.Configuration; to the top of the code.

Any help would be appreciated,

Nick
Reply With Quote
  #2 (permalink)  
Old April 2nd, 2012, 08:15 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Nick,

Your throw statement is outside the curly brace of the getter, while it should be inside. That should fix both problems as a) the throw statement is now in a valid location, and b) the getter returns something (or throws an error) on all code paths.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
Nick Makin (April 2nd, 2012)
  #3 (permalink)  
Old April 2nd, 2012, 08:45 AM
Authorized User
Points: 170, Level: 3
Points: 170, Level: 3 Points: 170, Level: 3 Points: 170, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 43
Thanks: 11
Thanked 0 Times in 0 Posts
Default

Wow! Can't believe I missed that one,

Thanks again Imar,

Nick
Reply With Quote
  #4 (permalink)  
Old April 2nd, 2012, 08:53 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Looks like you found the Global class? ;-)

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #5 (permalink)  
Old April 2nd, 2012, 09:51 AM
Authorized User
Points: 170, Level: 3
Points: 170, Level: 3 Points: 170, Level: 3 Points: 170, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 43
Thanks: 11
Thanked 0 Times in 0 Posts
Default

Haha yep!

Was something I remember reading through the other day and thought "what is that?" so I thought I'd ask, but then realised when I was looking through my Solution Explorer that I had the Global.asax file sat right in front of me so tried to delete the post!

Nick
Reply With Quote
  #6 (permalink)  
Old April 2nd, 2012, 10:41 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Quote:
so tried to delete the post!
I noticed. But I get notifications by e-mail, so I saw your question before you deleted it.... ;-)

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Chapter 19, Page 720 BobRoberts BOOK: Beginning ASP.NET 4 : in C# and VB 2 November 4th, 2011 12:38 PM
Typo on Page 19 agilitator BOOK: Discovering SQL: A Hands-On Guide for Beginners 0 June 6th, 2011 01:35 PM
chapter 19 page 660 Cannot Create a New Database Mike_Pliskin BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4 4 September 5th, 2010 01:52 PM
Chapter 19 - page 641 Struct RegisrtationInformation bon_chan BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4 1 July 29th, 2010 03:49 PM
Chapter 19 johanyu BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 3 November 12th, 2007 10:50 AM



All times are GMT -4. The time now is 02:39 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.