Hellow,
I'm reading asp.net 2.0 website programming Problem Design and Solution and I got a big problem in chapter 3
when I try to do this cast:
Public NotInheritable Class Globals
...
'pag 103
Public Shared ReadOnly Settings As TheBeerHouseSection = _
CType(WebConfigurationManager.GetSection("theBeerH ouse"), MB.TheBeerHouse.TheBeerHouseSection)
End Class
I got this error:
Server Error in '/MyTheBeerHouse' Application.
--------------------------------------------------------------------------------
Unable to cast object of type
'MB.TheBeerHouse.TheBeerHouseSection' to type
'MyTheBeerHouse.MB.TheBeerHouse.TheBeerHouseSectio n'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Unable to cast object of type 'MB.TheBeerHouse.TheBeerHouseSection' to type 'MyTheBeerHouse.MB.TheBeerHouse.TheBeerHouseSectio n'.
Source Error:
Line 18: 'pag 103
Line 19: 'todo: estou tendo um erro aqui
Line 20: Public Shared ReadOnly Settings As TheBeerHouseSection = _
Line 21: CType(WebConfigurationManager.GetSection("theBee rHouse"), MB.TheBeerHouse.TheBeerHouseSection)
Line 22:
Source File: D:\Visual Studio 2005\LIVRO WebSite Programming\MyTheBeerHouse\MyTheBeerHouse\App_Code \Globals.
vb Line: 20
Stack Trace:
[InvalidCastException: Unable to cast object of type 'MB.TheBeerHouse.TheBeerHouseSection' to type 'MyTheBeerHouse.MB.TheBeerHouse.TheBeerHouseSectio n'.]
MyTheBeerHouse.MB.TheBeerHouse.Globals..ccto r() in D:\Visual Studio 2005\LIVRO WebSite Programming\MyTheBeerHouse\MyTheBeerHouse\App_Code \Globals.
vb:20
[TypeInitializationException: The type initializer for 'MyTheBeerHouse.MB.TheBeerHouse.Globals' threw an exception.]
MyTheBeerHouse.MB.TheBeerHouse.UI.BasePage.O nPreInit(EventArgs e) in D:\Visual Studio 2005\LIVRO WebSite Programming\MyTheBeerHouse\MyTheBeerHouse\App_Code \BasePage.
vb:10
System.Web.UI.Page.ProcessRequestMain(Boolea n includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +663
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433
Someone could help me?
and another question:
What is the difference between
'MB.TheBeerHouse.TheBeerHouseSection' and
'MyTheBeerHouse.MB.TheBeerHouse.TheBeerHouseSectio n'