Can I
Member
hello,
I'm creating an instance of ShoppingCart class when session starts:
and using it in my ShoppingCart Web Control
and that works fine, but when I don't use fully qualified class name, like this:
I'm getting class cast exception:
isn't it odd?
I'm creating an instance of ShoppingCart class when session starts:
VB.NET:
<%@ Import Namespace="Code.business.shopping_cart" %>
...
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a new session is started
Session("shoppingCart") = New ShoppingCart()
End Sub
and using it in my ShoppingCart Web Control
VB.NET:
Imports Code.business.shopping_cart
...
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim shoppingCart As Code.business.shopping_cart.ShoppingCart = Session("shoppingCart")
...
End Sub
and that works fine, but when I don't use fully qualified class name, like this:
VB.NET:
Dim shoppingCart As ShoppingCart = Session("shoppingCart")
Unable to cast object of type 'Code.business.shopping_cart.ShoppingCart' to type 'ShoppingCart'.
isn't it odd?