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
  #1 (permalink)  
Old February 23rd, 2008, 01:11 PM
Registered User
 
Join Date: Nov 2006
Location: , , United Kingdom.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Unable to cast object of type 'TheBeerHouseSection

I can't seem to get this to work I keep getting an error with regards to:

public readonly static TheBeerHouseSection Settings =
  (TheBeerHouseSection)WebConfigurationManager.GetSe ction("theBeerHouse");

error:
Unable to cast object of type 'TheBeerHouseSection' to type 'TheBeerHouseSection'.

in debug mode I can see the values but for some reason the Settings Variable goes to null before being able to call any of the properties read from the webconfig file!!!

  #2 (permalink)  
Old February 23rd, 2008, 05:09 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

This is certainly a weird one.

I can't say if this relates directly to this issue, but I had a project that had a very similar issue with a masterpage.

I solved it by by clearing the Visual Studio temp files, which are created during the compile process.



  #3 (permalink)  
Old February 23rd, 2008, 08:39 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Atlanta, Georgia, USA.
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's normally caused by having double declarations, which means an extra temp assembly, as Lee pointed out. This can also happen if an extra source code file gets into the app_code folder.

Eric

  #4 (permalink)  
Old February 26th, 2008, 11:54 AM
Registered User
 
Join Date: Nov 2006
Location: , , United Kingdom.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Not quite sure how the issue was resolved, but I just moved the offending code out of the App_Code folder recompiled and then re inserted the code, it works now.

  #5 (permalink)  
Old June 10th, 2008, 12:13 PM
Registered User
 
Join Date: Jun 2008
Location: São Paulo, SP, Brazil.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had the exact same problem, but I couldn't solve yet.

This is the exception

System.TypeInitializationException was unhandled by user code
  Message="The type initializer for 'MyTheBeerHouse.MB.TheBeerHouse.Globals' threw an exception."
  Source="MyTheBeerHouse"
  TypeName="MyTheBeerHouse.MB.TheBeerHouse.Globals"
  StackTrace:
       at MyTheBeerHouse.MB.TheBeerHouse.UI.BasePage.OnPreIn it(EventArgs e) in D:\Visual Studio 2005\LIVRO WebSite Programming\MyTheBeerHouse\MyTheBeerHouse\App_Code \BasePage.vb:line 10
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Please, if someone could help me to solve this problem, I'll appreciate !!!

pedro_abs@yahoo.com.br





Similar Threads
Thread Thread Starter Forum Replies Last Post
Receiving Error Msg:Unable to cast object of type cesemj ASP.NET 2.0 Basics 2 March 4th, 2008 02:18 PM
Unable to cast object of type galua SQL Language 3 January 9th, 2008 01:31 PM
problem in cast of type yoord SQL Language 1 October 18th, 2004 03:19 PM





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