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

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

问题描述

我使用MVC .NET与CSLA分布式环境和我可以引用HttpPostedFileBase从我的web层之一(例如Website.MVC),但我的不能参考HttpPostedFileBase从一个单独的层(可以称之为OtherLayer.Web)。



这是什么,我需要做的,能够调用HttpPostedFileBase任何想法?
我可以使用HttpPostedFile在这两个层次 - ?应该我只是用这个代替



集引用基本上是相同的 - 在Website.MVC我有

 命名空间Website.Mvc.Controllers 
{使用系统
; System.Collections中使用
;
使用System.Collections.Generic;
使用System.Web.Mvc;
使用的System.Web;
:使用System.IO;使用PetOrganizer.Mvc.Helpers
;
使用TrupanionPetInsurance.Web;



而在我的另一层我有:

 使用系统命名空间OtherLayer.Web 
{
; System.Collections中使用
;
使用System.Collections.Generic;
使用System.Collections.Specialized;
使用System.Data这;
使用System.Data.SqlClient的;
:使用System.IO;
使用System.Net.Mail;
使用System.Text;使用System.Text.RegularExpressions
;
使用的System.Web;
使用System.Web.Mvc;
使用System.Web.Security;
使用的System.Xml;
使用的System.Xml.Serialization;
使用CSLA;
使用iTextSharp.text;使用iTextSharp.text.pdf
;
使用TruDat.BusinessLayer;使用TruDat.BusinessLayer.Billing
;使用TruDat.BusinessLayer.Data
;
使用TruDat.BusinessLayer.Utility;
使用TrupanionPetInsurance.Web.EmailTemplateParser;使用TruDat.BusinessLayer.DataServices
;


解决方案

请确保您的项目引用 System.Web.Abstractions 组件,该组件包含 <$ C 。$ C> HttpPostedFileBase 类型



由于混乱,因为它看起来的的 HttpPostedFile 型生活在一个单独的组件( >的System.Web ),但完全相同的命名空间。



要记住,命名空间可以跨越组件和程序集的名字是很重要的不一定决定包含在它的类型的命名空间。没有 System.Web.Abstractions 命名的只是两个程序集包含类型的的System.Web 命名



一旦你引用的两个组件,你可以通过它们不合格的名称与此单using语句引用两种类型:

 使用的System.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).

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?

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;

解决方案

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

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

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.

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天全站免登陆