29
votes

I've just tried deploying an MVC3 application to our IIS7 hosting environment but I'm being presented wtih the following exception:

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'.

Any suggestions?

The app isn't being bin deployed as I have installed ASP.Net Web pages and MVC3 on the web server itself.

4
Just to be clear, I'm not bin deploying this app - I already have MVC3 installed on the server.Phil.Wheeler
What other ways are there to deploy an app?Shawn Mclean
@Shawn - If someone says "just bin Deploy it" they mean "deploy the application with the dependencies copied into the application's /bin folder, rather than running an MSI that installs the dependencies into the Global Assembly Cache (GAC)." - Scott HanselmanPhil.Wheeler

4 Answers

54
votes

This is because Microsoft.Web.Infrastructure is 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.

Copy Local

Output (Ignore the Ninject and NCU):

alt text

11
votes

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.

I then removed the line of code in the packages.config file

<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.

6
votes

Microsoft.Web.Infrastructure is now a Nuget package, and it can be added to your project to enable bin directory deployments --

http://nuget.org/packages/Microsoft.Web.Infrastructure

2
votes

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:

<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.