asp.net-mvc MVC3 部署依赖问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4742894/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MVC3 Deployment Dependency Problems
提问by Phil.Wheeler
I've just tried deploying an MVC3 application to our IIS7 hosting environment but I'm being presented wtih the following exception:
我刚刚尝试将 MVC3 应用程序部署到我们的 IIS7 托管环境,但出现以下异常:
Could not load type 'Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility' from assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.TypeLoadException: Could not load type 'Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility' from assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
无法从程序集“Microsoft.Web.Infrastructure,版本=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”加载类型“Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility”。说明:在执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其起源于代码的更多信息。
异常详细信息:System.TypeLoadException:无法从程序集“Microsoft.Web.Infrastructure,Version=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”加载类型“Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility”。
Any suggestions?
有什么建议?
The app isn't being bin deployed as I have installed ASP.Net Web pages and MVC3 on the web server itself.
由于我已经在 Web 服务器本身上安装了 ASP.Net 网页和 MVC3,因此该应用程序没有被 bin 部署。
回答by Shawn Mclean
This is because Microsoft.Web.Infrastructureis not in your GAC. You need to add this reference to your project. Right click the reference and go to properties then set copy to local to true.
这是因为Microsoft.Web.Infrastructure不在您的 GAC 中。您需要将此引用添加到您的项目中。右键单击引用并转到属性,然后将 copy to local 设置为 true。


Output (Ignore the Ninject and NCU):
输出(忽略 Ninject 和 NCU):


回答by riaandl
It turns out after doing a Reference Cleaning, it removed Microsoft.Web.Infrastructure, but not from the packages.config file. After trying to add it again using the Package Manager Console, Visual Studio says that it is already installed which is false because it was removed.
事实证明,在执行引用清理后,它删除了Microsoft.Web.Infrastructure,但没有从 packages.config 文件中删除。在尝试使用 再次添加它后Package Manager Console,Visual Studio 说它已经安装,这是错误的,因为它已被删除。
I then removed the line of code in the packages.configfile
然后我删除了packages.config文件中的代码行
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
and ran the command again
并再次运行命令
PM> Install-Package Microsoft.Web.Infrastructure
After this, now it works fine.
在此之后,现在它工作正常。
回答by Jason
Microsoft.Web.Infrastructureis now a Nuget package, and it can be added to your project to enable bin directory deployments --
Microsoft.Web.Infrastructure现在是一个 Nuget 包,它可以添加到您的项目中以启用 bin 目录部署 --
回答by marcind
Make sure that the root web.config file on your server (located somewhere like here: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config) has the following entry:
确保您的服务器上的根 web.config 文件(位于类似此处:)C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config具有以下条目:
<configuration>
<location allowOverride="true">
<system.web>
<fullTrustAssemblies>
<add
assemblyName="Microsoft.Web.Infrastructure"
version="1.0.0.0"
publicKey="[bunch of letters and numbers]"
/>
If it's missing then it means that somebody messed with your .NET 4 installation.
如果它丢失,则意味着有人搞乱了您的 .NET 4 安装。

