2015-04-28 74 views
0

在MVC的Web应用程序,我得到以下异常: enter image description here类型或命名空间名称“EmbeddedResourceVirtualPathProvider”找不到

在我的解决方案我都引用确定。可能是什么问题呢?

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: } 
+0

显然,你缺少你的项目参考。最好尝试删除并重新添加。 –

+0

是的,我这样做,我仍然有这个错误。 –

+0

尝试清理和重建您的项目。 –

回答

0

哇,这是一个有趣的。我发现了一个帖子的真正的解决方案:

检查项目输出路径(项目属性/编译)设置 到bin而不是bin\Releasebin\Debug

出于某种原因,IIS(VS开发服务器或本地IIS)总是 访问库从bin目录(并不会抬头为 子目录)

相关问题