C#の - 私は参照できませんHttpPostedFileBase
-
19-09-2019 - |
質問
私は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;
解決
あなたのプロジェクトは、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
名前空間の種類が含まれているだけで2つのアセンブリます。
あなたはこの単一のusingステートメントで自分の非修飾名で両方のタイプを参照することができます両方のアセンブリ参照たら:
をusing System.Web;
他のヒント
あなたのプロジェクトがHttpPostedFileBaseタイプが含まれているSystem.Web.Abstractionsアセンブリを参照することを確認します。
おかげで、アンドリュー・トリックをしたウサギ、まだ私は、.NET 4.0からというように、System.Web.Abstractionsが廃止されていることを信じて、あなたが代わりのSystem.Webへの参照を追加する必要があります。
私の場合は、それがその後、最終的な解決策だった。
using System.Web;
働いていたため、HttpPostedFileBaseが認められた。
感謝します。