Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC3 Deployment Dependency Problems

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.

like image 506
Phil.Wheeler Avatar asked Jan 20 '11 02:01

Phil.Wheeler


4 Answers

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

like image 101
Shawn Mclean Avatar answered Nov 06 '22 15:11

Shawn Mclean


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.

like image 27
Riaan Avatar answered Nov 06 '22 15:11

Riaan


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

like image 6
Jason Avatar answered Nov 06 '22 14:11

Jason


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.

like image 3
marcind Avatar answered Nov 06 '22 13:11

marcind