簡體   English   中英

找不到類型或名稱空間名稱“ EmbeddedResourceVirtualPathProvider”

[英]The type or namespace name 'EmbeddedResourceVirtualPathProvider' could not be found

在MVC Web應用程序中,出現以下異常: 在此處輸入圖片說明

在我的解決方案中,我有所有引用。 可能是什么問題呢?

Show Detailed Compiler Output:


C:\Program Files (x86)\IIS Express> "C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" /t:library /utf8output /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.DynamicData\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.DynamicData.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.VisualStudio.Web.PageInspector.Loader\v4.0_1.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Web.PageInspector.Loader.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Extensions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\7aca0e01\527e5722\assembly\dl3\f1797493\0a6847cc_a781d001\MES_WebShell_Contract.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\7aca0e01\527e5722\assembly\dl3\e90790ee\6d927a72_8a81d001\WebActivatorEx.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\7aca0e01\527e5722\assembly\dl3\a12d02d2\2b7a5d18_0e5cd001\Microsoft.Practices.Unity.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Web\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Deployment\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Deployment.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.Activities.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activities.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.WorkflowServices\v4.0_4.0.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.IdentityModel\v4.0_4.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\7aca0e01\527e5722\assembly\dl3\d5f7acc0\6b36ac18_0e5cd001\Microsoft.Practices.Unity.Mvc.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\7aca0e01\527e5722\assembly\dl3\3b971db3\b1f9174f_0c92cf01\Common.Library.Core.State.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Deployment\v4.0_1.0.0.0__31bf3856ad364e35\System.Web.WebPages.Deployment.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activation\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activation.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.ApplicationServices\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.ApplicationServices.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\7aca0e01\527e5722\assembly\dl3\963f5834\6b345918_0e5cd001\Microsoft.Practices.Unity.Configuration.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\7aca0e01\527e5722\assembly\dl3\89a8fa3f\6336b4cc_a781d001\MES_WebShell_Business.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Services\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\7aca0e01\527e5722\assembly\dl3\decdd4ca\7bae6018_0e5cd001\Microsoft.Practices.Unity.RegistrationByConvention.dll" /out:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\7aca0e01\527e5722\App_Code.tekse26w.dll" /D:DEBUG /debug+ /optimize- /w:4 /nowarn:1659;1699;1701;612;618 /warnaserror-  "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\7aca0e01\527e5722\App_Code.tekse26w.0.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\7aca0e01\527e5722\App_Code.tekse26w.1.cs"


Microsoft (R) Visual C# Compiler version 4.0.30319.34209

for Microsoft (R) .NET Framework 4.5
Copyright (C) Microsoft Corporation. All rights reserved.

d:\Projects\MES_FraMES\Web Applications\MES_WebShell\1\trunk\Solution\MES_WebShell\MES_WebShell\App_Code\RegisterVirtualPathProvider.cs(4,7): error CS0246: The type or namespace name 'EmbeddedResourceVirtualPathProvider' could not be found (are you missing a using directive or an assembly reference?)

Show Complete Compilation Source:


Line 1:    using System.Linq;
Line 2:    using System.Reflection;
Line 3:    using System.Web.Hosting;
Line 4:    using EmbeddedResourceVirtualPathProvider;
Line 5:    
Line 6:    namespace MES_WebShellLine 7:    {Line 8:        public class RegisterVirtualPathProviderLine 9:        {Line 10:           public static void AppInitialize()Line 11:           {Line 12:               //By default, we scan all non system assemblies for embedded resourcesLine 13:               var assemblies = System.Web.Compilation.BuildManager.GetReferencedAssemblies()Line 14:                   .Cast<Assembly>()Line 15:                   .Where(a => a.GetName().Name.StartsWith("System") == false);            Line 16:               HostingEnvironment.RegisterVirtualPathProvider(new Vpp(assemblies.ToArray())Line 17:               {Line 18:                   //you can do a specific assembly registration too. If you provide the assemly source path, it can readLine 19:                  //from the source file so you can change the content while the app is running without needing to rebuildLine 20:                //{typeof(SomeAssembly.SomeClass).Assembly, @"..\SomeAssembly"} Line 21:               });Line 22:           }Line 23:       }Line 24:   }

哇,真有趣。 我在帖子中找到了真正的解決方案:

檢查項目輸出路徑(項目屬性/ Build)是否設置為bin而不是bin\\Releasebin\\Debug

出於某種原因,IIS(VS開發服務器或本地IIS)總是從bin目錄訪問庫(並且不會查找子目錄)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM