問題描述
我在具有 CSLA 的分布式環(huán)境中使用 MVC .NET,并且我可以從我的一個(gè) Web 層(例如 Website.MVC)引用 HttpPostedFileBase,但我不能從單獨(dú)的層引用 HttpPostedFileBase(我們稱之為 OtherLayer.Web).
I am using MVC .NET in a distributed environment with CSLA and I can reference HttpPostedFileBase from one of my web layers (eg Website.MVC), but I cannot reference HttpPostedFileBase from a separate layer (lets call it OtherLayer.Web).
知道我需要做什么才能調(diào)用 HttpPostedFileBase 嗎?我可以在兩個(gè)層中使用 HttpPostedFile - 我應(yīng)該只使用它嗎?
Any idea on what I need to do to be able to call HttpPostedFileBase ? I am able to use HttpPostedFile in both layers - should I just use this instead?
程序集引用基本相同 - 在 Website.MVC 我有:
The assembly references are basically the same - in Website.MVC I have:
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;
而在我的另一層中,我有:
Whereas in my other layer i have:
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;
推薦答案
確保您的項(xiàng)目引用了 System.Web.Abstractions
程序集,其中包含 HttpPostedFileBase
類型.
Make sure your project references the System.Web.Abstractions
assembly which contains the HttpPostedFileBase
type.
雖然看起來很混亂,但 HttpPostedFile
類型位于單獨(dú)的程序集 (System.Web
) 中,但具有完全相同的命名空間.
As confusing as it may seem, the HttpPostedFile
type lives in a separate assembly (System.Web
) but the same exact namespace.
請(qǐng)務(wù)必記住,命名空間可以跨越程序集,并且程序集的名稱不一定指示其中包含的類型的命名空間.沒有 System.Web.Abstractions
namespace 只是兩個(gè)包含 System.Web
命名空間中的類型的程序集.
It is important to remember that the namespaces can span assemblies and the name of an assembly does not necessarily dictate the namespace of the types contained in it. There is no System.Web.Abstractions
namespace simply two assemblies that contain types in the System.Web
namespace.
一旦你引用了這兩個(gè)程序集,你就可以使用這個(gè)單一的 using 語句通過它們的非限定名稱來引用這兩種類型:
Once you have referenced both assemblies you can reference both types by their unqualified names with this single using statement:
using System.Web;
這篇關(guān)于C# - 我無法引用 HttpPostedFileBase的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!