C# - 我不能引用HttpPostedFileBase
-
19-09-2019 - |
题
我使用MVC .NET与CSLA分布式环境和我可以强>参考HttpPostedFileBase从我的网页层中的一个(例如Website.MVC),但我的不能强>参考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;
解决方案
请确保您的项目引用其中包含System.Web.Abstractions装配href="http://msdn.microsoft.com/en-us/library/system.web.httppostedfilebase.aspx" rel="noreferrer"> HttpPostedFileBase
类型。
由于混乱,因为它看起来,在 HttpPostedFile
一>型住在一个单独的组件(System.Web
),但相同的确切名称空间。
要记住,命名空间可以跨越组件和组件的名称并不一定指示包含在其中的类型的名称空间是很重要的。没有System.Web.Abstractions
命名空间简单地两个组件包含在System.Web
命名空间的类型。
一旦你引用的两个组件,你可以通过它们不合格的名称与此单using语句引用两种类型:
using System.Web;
其他提示
请确保您的项目引用System.Web.Abstractions组件,其包含HttpPostedFileBase类型。
感谢,安德鲁野兔,该诀窍,但我认为,从.NET 4.0等,System.Web.Abstractions已被弃用,你应该添加引用,而不是对System.Web程序。
在我的情况下,这是最终的解决办法,在这之后
using System.Web;
工作,并且因此,HttpPostedFileBase被确认。
感谢。