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: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 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
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 16th, 2008, 07:38 AM
Registered User
 
Join Date: Apr 2008
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with Chapter 3 Type Initialization error

Im having a problem with the vb version i am getting an error in the basePage class
at the dim id as string = globals.themeselectorID
'Type initializer for 'MB.TheBeerHouse.Globals' threw an exception. i cant figure out how to solve this problem

if i do a debug and enter globals.themesselector into watch it says that its not a member of globals. but in the code intellisense picks up all properties
  #2 (permalink)  
Old April 16th, 2008, 10:48 AM
Registered User
 
Join Date: Apr 2008
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i solved the problem my web.config file was incorrect.

  #3 (permalink)  
Old April 22nd, 2008, 01:56 PM
Registered User
 
Join Date: Apr 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What did you do, I'm get the same error in the c# version.

  #4 (permalink)  
Old April 24th, 2008, 08:42 AM
Registered User
 
Join Date: Apr 2008
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I just copied the web.config file from the completed sample chapter and made sure all my page inherits were correct

  #5 (permalink)  
Old May 21st, 2008, 09:06 AM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I am also recieving this error and cannot figure it out. I have taken the site back down to a working version (chapter 2) and found that it was the following C# code that is causing the issue. I have checked the web.config file and it is the same as the chapter by chapter (which I would like to add, does not work on my machine either). All of the references are the same.

Code:
public readonly static TheBeerHouseSection Settings =
          (TheBeerHouseSection)WebConfigurationManager.GetSection("theBeerHouse");


It is like the Globals class is not being initialized and I am not sure why. Any help would be greatly appreciated.

Thanks,
Patrick

  #6 (permalink)  
Old May 21st, 2008, 10:42 AM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I actually found a work around, not sure why I was having trouble but this seemed to fix the issue.

Code:
public static TheBeerHouseSection Settings
{
    get
    {
        return (TheBeerHouseSection)WebConfigurationManager.GetSection("theBeerHouse");
    }
}
  #7 (permalink)  
Old April 9th, 2009, 05:57 PM
Registered User
 
Join Date: Mar 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very very much patrickst1. Your explicit initialization worked for me too. I am posting the entire class with working and not working codes.

Mike1298


using System;
using System.Data;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace MB.TheBeerHouse.App_Code
{
publicstaticclassGlobals
{
publicstaticstring ThemesSelectorID = "";
#if (false)
/* The offending constructor/initializer */
public readonly static TheBeerHouseSection Settings =
(TheBeerHouseSection)WebConfigurationManager.GetSe ction("theBeerHouse");
#else
// replaced it by the following and it workd.
// Both do the same thing. The explicit one works.
publicstaticTheBeerHouseSection Settings
{
get
{
return (TheBeerHouseSection)WebConfigurationManager.GetSection("theBeerHouse");
}
}
#endif
}
}
  #8 (permalink)  
Old April 9th, 2009, 06:07 PM
Registered User
 
Join Date: Mar 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The same code as above, except it is more readable.
Mike1298

using System;
using System.Data;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace MB.TheBeerHouse.App_Code
{
publicstaticclassGlobals
{
publicstaticstring ThemesSelectorID = "";

#if (false)
/* The offending constructor/initializer */

public readonly static TheBeerHouseSection Settings =
(TheBeerHouseSection)WebConfigurationManager.GetSe ction("theBeerHouse");
#else
// Replaced it by the following and it workd.
// Both do the same thing. The explicit one works.

publicstaticTheBeerHouseSection Settings
{
get
{
return (TheBeerHouseSection)WebConfigurationManager.GetSection("theBeerHouse");
}
}
#endif
}
}
 


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
Error occurred during initialization of VM dinesh.choudhary Java Espanol 3 December 10th, 2014 07:54 AM
Error occurred during initialization of VM elisabeth Java Espanol 2 October 8th, 2004 09:50 AM
Error in Correlation Property Initialization vijay_rb Biztalk 1 August 17th, 2004 08:17 AM
Setup Initialization Error RobinR MySQL 1 April 6th, 2004 02:49 PM
Initialization error"adOpenforwardOnly" ali Classic ASP Basics 7 October 27th, 2003 01:30 PM



All times are GMT -4. The time now is 11:04 PM.


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