C# - 我不能引用 HttpPostedFileBase [英] C# - I cannot reference HttpPostedFileBase

查看:73
本文介绍了C# - 我不能引用 HttpPostedFileBase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在具有 CSLA 的分布式环境中使用 MVC .NET,并且我可以从我的网络层之一(例如 Website.MVC)引用 HttpPostedFileBase,但我不能从一个单独的层引用 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).

知道我需要做什么才能调用 HttpPostedFileBase 吗?我可以在两个层中使用 HttpPostedFile - 我应该使用它吗?

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;

推荐答案

确保您的项目引用了 System.Web.Abstractions 程序集,其中包含 HttpPostedFileBase 类型.

Make sure your project references the System.Web.Abstractions assembly which contains the HttpPostedFileBase type.

尽管看起来令人困惑,HttpPostedFile 类型位于单独的程序集 (System.Web) 中,但具有完全相同的命名空间.

As confusing as it may seem, the HttpPostedFile type lives in a separate assembly (System.Web) but the same exact namespace.

重要的是要记住命名空间可以跨越程序集,程序集的名称不一定决定其中包含的类型的命名空间.没有 System.Web.Abstractions namespace 只是两个包含 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.

一旦你引用了两个程序集,你就可以使用这个单一的 using 语句通过它们的非限定名称来引用这两个类型:

Once you have referenced both assemblies you can reference both types by their unqualified names with this single using statement:

using System.Web;

这篇关于C# - 我不能引用 HttpPostedFileBase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆