petshop中的CART不存在,怎么跟这个文件有关吧\App_Code.ifbadgzl.0.cs
错误 1 命名空间“PetShop.BLL”中不存在类型或命名空间名称“Cart”(是缺少程序集引用吗?) c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\petshop\c77f93e4\6fe0916b\App_Code.ifbadgzl.0.cs 19错误 2 命名空间“PetShop.BLL”中不存在类型或命名空间名称“Cart”(是缺少程序集引用吗?) c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\petshop\c77f93e4\6fe0916b\App_Code.ifbadgzl.0.cs 28
app_code.rswc6_gk.0.cs
using System;
using System.Web;
using System.Web.Profile;
public class ProfileCommon : System.Web.Profile.ProfileBase {
/// <summary>
///
/// </summary>
/// ???????????????????????????????????????????????/
public virtual PetShop.BLL.Cart ShoppingCart {
get {
return ((PetShop.BLL.Cart)(this.GetPropertyValue("ShoppingCart")));
}
set {
this.SetPropertyValue("ShoppingCart", value);
}
}
???????????????????????????????????????????????????/
public virtual PetShop.BLL.Cart WishList {
get {
return ((PetShop.BLL.Cart)(this.GetPropertyValue("WishList")));
}
set {
this.SetPropertyValue("WishList", value);
}
}
public virtual PetShop.Model.AddressInfo AccountInfo {
get {
return ((PetShop.Model.AddressInfo)(this.GetPropertyValue("AccountInfo")));
}
set {
this.SetPropertyValue("AccountInfo", value);
}
}
public virtual ProfileCommon GetProfile(string username) {
return ((ProfileCommon)(ProfileBase.Create(username)));
}
}
cart.cs
using System;
using System.Collections.Generic;
using PetShop.Model;
namespace PetShop.BLL {
/// <summary>
/// An object to represent a customer's shopping cart.
/// This class is also used to keep track of customer's wish list.
/// </summary>
[Serializable]
public class Cart {
// Internal storage for a cart
private Dictionary<string, CartItemInfo> cartItems = new Dictionary<string, CartItemInfo>();
/// <summary>
/// Calculate the total for all the cartItems in the Cart
/// </summary>
public decimal Total {
get {
decimal total = 0;
foreach (CartItemInfo item in cartItems.Values)
total += item.Price * item.Quantity;
return total;
}
}
/// <summary>
/// Update the quantity for item that exists in the cart
/// </summary>
/// <param name="itemId">Item Id</param>
/// <param name="qty">Quantity</param>
public void SetQuantity(string itemId, int qty) {
cartItems[itemId].Quantity = qty;
}
/// <summary>
/// Return the number of unique items in cart
/// </summary>
public int Count {
get { return cartItems.Count; }
}
/// <summary>
/// Add an item to the cart.
/// When ItemId to be added has already existed, this method will update the quantity instead.
/// </summary>
/// <param name="itemId">Item Id of item to add</param>
public void Add(string itemId) {
CartItemInfo cartItem;
if (!cartItems.TryGetValue(itemId, out cartItem)) {
Item item = new Item();
ItemInfo data = item.GetItem(itemId);
if (data != null) {
CartItemInfo newItem = new CartItemInfo(itemId, data.ProductName, 1, (decimal)data.Price, data.Name, data.CategoryId, data.ProductId);
cartItems.Add(itemId, newItem);
}
}
else
cartItem.Quantity++;
}
/// <summary>
/// Add an item to the cart.
/// When ItemId to be added has already existed, this method will update the quantity instead.
/// </summary>
/// <param name="item">Item to add</param>
public void Add(CartItemInfo item) {
CartItemInfo cartItem;
if (!cartItems.TryGetValue(item.ItemId, out cartItem))
cartItems.Add(item.ItemId, item);
else
cartItem.Quantity += item.Quantity;
}
/// <summary>
/// Remove item from the cart based on itemId
/// </summary>
/// <param name="itemId">ItemId of item to remove</param>
public void Remove(string itemId) {
cartItems.Remove(itemId);
}
/// <summary>
/// Returns all items in the cart. Useful for looping through the cart.
/// </summary>
/// <returns>Collection of CartItemInfo</returns>
public ICollection<CartItemInfo> CartItems {
get { return cartItems.Values; }
}
/// <summary>
/// Method to convert all cart items to order line items
/// </summary>
/// <returns>A new array of order line items</returns>
public LineItemInfo[] GetOrderLineItems() {
LineItemInfo[] orderLineItems = new LineItemInfo[cartItems.Count];
int lineNum = 0;
foreach (CartItemInfo item in cartItems.Values)
orderLineItems[lineNum] = new LineItemInfo(item.ItemId, item.Name, ++lineNum, item.Quantity, item.Price);
return orderLineItems;
}
/// <summary>
/// Clear the cart
/// </summary>
public void Clear() {
cartItems.Clear();
}
}
}
--------------------编程问答-------------------- up --------------------编程问答-------------------- 估计是你把BLL中的Cart给删掉了吧!所以出现这些错误,你所贴出来的代码其实是又web.config文件的配置生成的,所以你必须修改web.config中,关于Cart部分的定义。
补充:.NET技术 , C#