对注册表项 HKEY_CLASSES_ROOT\logistics.BusinessRules.Wharehouse 的访问被拒绝。
异常详细信息: System.UnauthorizedAccessException: 对注册表项 HKEY_CLASSES_ROOT\logistics.BusinessRules.Wharehouse 的访问被拒绝。
未授权此 ASP.NET 进程访问所请求的资源。出于安全原因,默认的 ASP.NET 进程标识为“{machinename}\ASPNET”,它只具有有限的特权。请考虑授予该 ASP.NET 进程标识访问此资源的权限。
若要授予 ASP.NET 对文件的写访问权,请在资源管理器中右击该文件,选择“属性”,然后选择“安全”选项卡。单击“添加”以添加“{machinename}\ASPNET”用户。突出显示此 ASP.NET 帐户,在“允许”列中选中“写”框。
源错误:
行 16: public static void StoreProductIntoWharehouse(EntityData entity)
行 17: {
出错行 18: Wharehouse house=new Wharehouse();
行 19: house.StoreIntoWarehouse(entity);
行 20: }
下面是我的定义Wharehouse类
using System;
using Jobsinfo;
using System.Data;
using System.EnterpriseServices;
using logistics.EntityDAO;
namespace logistics.BusinessRules
{
/// <summary>
/// Wharehouse 的摘要说明。
/// </summary>
//设置事务处理类型
[Transaction(TransactionOption.Required)]
//继承ServicedComponent,以支持使用Windows的Transaction Service
public class Wharehouse : System.EnterpriseServices.ServicedComponent
{
public Wharehouse()
{
}
//入库的业务逻辑代码
public void StoreIntoWarehouse(EntityData IndepotForm)
{
//得到入库单明细
DataTable tbl=IndepotForm.Tables["InDepotFormDetail"];
try
{
//对于入库单明细中的每个产品,都要修改原有产品的库存数量
ProductEntityDAO ped=new ProductEntityDAO();
for(int i=0;i<tbl.Rows.Count;i++)
{
//得到入库单明细的一个产品信息
DataRow formdetail=tbl.Rows[i];
string productID=formdetail["ProductID"].ToString();
decimal inCount=(decimal)formdetail["InCount"];
//找到需要修改库存数量的产品
EntityData product=ped.FindByPrimaryKey(productID);
DataRow productRow=product.GetRecord("Product");
//修改产品库存数量
productRow["CurrentCount"]=(decimal)productRow["CurrentCount"]+inCount;
ped.UpdateEntity(product);
}
ped.Dispose();
InDepotFormEntityDAO inDepotForm=new InDepotFormEntityDAO();
inDepotForm.InsertEntity(IndepotForm);
IndepotForm.Dispose();
ContextUtil.SetComplete();
}
catch(Exception ee)
{
ContextUtil.SetAbort();
throw ee;
}
}
}
}