Wrox Programmer Forums
| 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 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 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
 
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.

 
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.

 
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

 
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

 
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");
    }
}
 
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
}
}
 
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
}
}




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





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