System.ArgumentNullException: Value cannot be null. [modified]
-
my project is running locally fine. But when i upload it shows below error [ArgumentNullException: Value cannot be null. Parameter name: type] System.Activator.CreateInstance(Type type, Boolean nonPublic) +7465206 System.Web.Profile.ProfileBase.CreateMyInstance(String username, Boolean isAuthenticated) +79 System.Web.Profile.ProfileBase.Create(String username, Boolean isAuthenticated) +231 System.Web.HttpContext.get_Profile() +107 ProductsAccordingCat.get_Profile() +49 ProductsAccordingCat.gotoCart(Object sender, EventArgs e) in ProductsAccordingCat.aspx.cs:696 System.Web.UI.ImageClickEventHandler.Invoke(Object sender, ImageClickEventArgs e) +0 System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +108 System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +118 System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565 Please help me to solve this problem. below is code protected void gotoCart(object sender, EventArgs e) { ImageButton btn = (ImageButton)sender; double Price = double.Parse(((Label)btn.Parent.FindControl("Price")).Text);//.Substring(8)); string ProductName = ((HyperLink)btn.Parent.FindControl("hlnkProductName")).Text; string ImagePath = ((System.Web.UI.WebControls.Image)btn.Parent.FindControl("imgProduct")).ImageUrl; string ProductID1 = ((HtmlInputHidden)btn.Parent.FindControl("hdnid")).Value; string ParentID = ((HtmlInputHidden)btn.Parent.FindControl("hdnParentID")).Value; int ProductID = Convert.ToInt32(ProductID1.Substring(1)); if (Profile.Cart == null) // here at this line it shows error { Profile.Cart = new shopping.ShoppingCart(); } Profile.Cart.Insert(ProductID, Price,0, 1, ProductName, ImagePath); Response.Redirect(ResolveUrl("~") + "Shopping_Cart/ShoppingCart.aspx"); }
modified on Tuesday, September 22, 2009 12:52 PM
-
my project is running locally fine. But when i upload it shows below error [ArgumentNullException: Value cannot be null. Parameter name: type] System.Activator.CreateInstance(Type type, Boolean nonPublic) +7465206 System.Web.Profile.ProfileBase.CreateMyInstance(String username, Boolean isAuthenticated) +79 System.Web.Profile.ProfileBase.Create(String username, Boolean isAuthenticated) +231 System.Web.HttpContext.get_Profile() +107 ProductsAccordingCat.get_Profile() +49 ProductsAccordingCat.gotoCart(Object sender, EventArgs e) in ProductsAccordingCat.aspx.cs:696 System.Web.UI.ImageClickEventHandler.Invoke(Object sender, ImageClickEventArgs e) +0 System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +108 System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +118 System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565 Please help me to solve this problem. below is code protected void gotoCart(object sender, EventArgs e) { ImageButton btn = (ImageButton)sender; double Price = double.Parse(((Label)btn.Parent.FindControl("Price")).Text);//.Substring(8)); string ProductName = ((HyperLink)btn.Parent.FindControl("hlnkProductName")).Text; string ImagePath = ((System.Web.UI.WebControls.Image)btn.Parent.FindControl("imgProduct")).ImageUrl; string ProductID1 = ((HtmlInputHidden)btn.Parent.FindControl("hdnid")).Value; string ParentID = ((HtmlInputHidden)btn.Parent.FindControl("hdnParentID")).Value; int ProductID = Convert.ToInt32(ProductID1.Substring(1)); if (Profile.Cart == null) // here at this line it shows error { Profile.Cart = new shopping.ShoppingCart(); } Profile.Cart.Insert(ProductID, Price,0, 1, ProductName, ImagePath); Response.Redirect(ResolveUrl("~") + "Shopping_Cart/ShoppingCart.aspx"); }
modified on Tuesday, September 22, 2009 12:52 PM
Can you show us the code where it is breaking down? The stack helps, but not that much.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
-
Can you show us the code where it is breaking down? The stack helps, but not that much.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
below is code protected void gotoCart(object sender, EventArgs e) { ImageButton btn = (ImageButton)sender; double Price = double.Parse(((Label)btn.Parent.FindControl("Price")).Text);//.Substring(8)); string ProductName = ((HyperLink)btn.Parent.FindControl("hlnkProductName")).Text; string ImagePath = ((System.Web.UI.WebControls.Image)btn.Parent.FindControl("imgProduct")).ImageUrl; string ProductID1 = ((HtmlInputHidden)btn.Parent.FindControl("hdnid")).Value; string ParentID = ((HtmlInputHidden)btn.Parent.FindControl("hdnParentID")).Value; int ProductID = Convert.ToInt32(ProductID1.Substring(1)); if (Profile.Cart == null) // here at this line it shows error { Profile.Cart = new shopping.ShoppingCart(); } Profile.Cart.Insert(ProductID, Price,0, 1, ProductName, ImagePath); Response.Redirect(ResolveUrl("~") + "Shopping_Cart/ShoppingCart.aspx"); }
-
below is code protected void gotoCart(object sender, EventArgs e) { ImageButton btn = (ImageButton)sender; double Price = double.Parse(((Label)btn.Parent.FindControl("Price")).Text);//.Substring(8)); string ProductName = ((HyperLink)btn.Parent.FindControl("hlnkProductName")).Text; string ImagePath = ((System.Web.UI.WebControls.Image)btn.Parent.FindControl("imgProduct")).ImageUrl; string ProductID1 = ((HtmlInputHidden)btn.Parent.FindControl("hdnid")).Value; string ParentID = ((HtmlInputHidden)btn.Parent.FindControl("hdnParentID")).Value; int ProductID = Convert.ToInt32(ProductID1.Substring(1)); if (Profile.Cart == null) // here at this line it shows error { Profile.Cart = new shopping.ShoppingCart(); } Profile.Cart.Insert(ProductID, Price,0, 1, ProductName, ImagePath); Response.Redirect(ResolveUrl("~") + "Shopping_Cart/ShoppingCart.aspx"); }
I would be interested to know if you ever found a solution. I too have recently come across this very same issue when trying to access the Profile object. I dont think it is related to this article some configuration issue on the server - look up MOSS and profile null.