C# – 我无法引用HttpPostedFileBase
我在CSLA的分布式环境中使用MVC .NET,我可以从我的一个Web层(例如Website.MVC)引用HttpPostedFileBase,但我不能从单独的层引用HttpPostedFileBase(我们称之为OtherLayer.Web)。
关于我需要做什么才能调用HttpPostedFileBase的任何想法? 我可以在两个层中使用HttpPostedFile – 我应该只使用它吗?
程序集引用基本相同 – 在Website.MVC我有:
namespace Website.Mvc.Controllers { using System; using System.Collections; using System.Collections.Generic; using System.Web.Mvc; using System.Web; using System.IO; using PetOrganizer.Mvc.Helpers; using TrupanionPetInsurance.Web;
而在我的另一层我有:
namespace OtherLayer.Web { using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Data; using System.Data.SqlClient; using System.IO; using System.Net.Mail; using System.Text; using System.Text.RegularExpressions; using System.Web; using System.Web.Mvc; using System.Web.Security; using System.Xml; using System.Xml.Serialization; using Csla; using iTextSharp.text; using iTextSharp.text.pdf; using TruDat.BusinessLayer; using TruDat.BusinessLayer.Billing; using TruDat.BusinessLayer.Data; using TruDat.BusinessLayer.Utility; using TrupanionPetInsurance.Web.EmailTemplateParser; using TruDat.BusinessLayer.DataServices;
确保您的项目引用包含HttpPostedFileBase
类型的System.Web.Abstractions
程序集。
尽管看起来令人困惑,但HttpPostedFile
类型存在于一个单独的程序集( System.Web
)中,但却是完全相同的命名空间。
重要的是要记住命名空间可以跨越程序集,程序集的名称不一定决定其中包含的类型的命名空间。 没有System.Web.Abstractions
命名空间只是两个包含System.Web
命名空间中的类型的程序集。
一旦引用了两个程序集,就可以使用这个单一的using语句通过非限定名称引用这两个类型:
using System.Web;
确保您的项目引用包含HttpPostedFileBase类型的System.Web.Abstractions程序集。
谢谢,Andrew Hare,这样做了,但我相信从.Net 4.0等等,不推荐使用System.Web.Abstractions,你应该添加对System.web的引用。
就我而言,那是最终的解决方案
using System.Web;
工作,因此,HttpPostedFileBase被认可。
谢谢。