0

My DNN website was working fine until I add a new module to it. Once I created a new module in VS 2015 DNN and added it to the site this error started occuring.

2016-10-05 12:37:38,851 [WIN-8EQ5384ADST][Thread:13][ERROR] DotNetNuke.Services.Exceptions.Exceptions - ~/Default.aspx?tabid=1216&error=An unexpected error has occurred&content=0
System.IO.FileLoadException: Could not load file or assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
   at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
   at System.Signature..ctor(IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
   at System.Reflection.RuntimeConstructorInfo.GetParametersNoCopy()
   at System.Reflection.RuntimeConstructorInfo.GetParameters()
   at System.Diagnostics.StackTrace.ToString(TraceFormat traceFormat)
   at System.Exception.GetStackTrace(Boolean needFileInfo)
   at LCE.DNN.Modules.StoreLocator.View.Page_Load(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

In the module web.config I see below:

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31BF3856AD364E35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Razor" publicKeyToken="31BF3856AD364E35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
            </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebMatrix.Data" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

And I don't see anything related System.Web.Razor in main web.config file(website config file).

I'm new to MVC and also DNN, Can some one guide me on this to fix this issue?

Jaggi
  • 170
  • 2
  • 5
  • 16
  • Well, you have duplicate bindings there, so I'd recommend fixing that first. There's also a web.config in the Views folder (assuming DNN follows the normal template for an MVC project). Also, make sure that whatever `LCE.DNN.Modules.StoreLocator` is, that it isn't referencing an older version of `System.Web.Razor`. – Tieson T. Oct 05 '16 at 17:12
  • @TiesonT. Can you brief it more. I don't understand where exactly you want me to look. – Jaggi Oct 05 '16 at 17:15
  • I honestly do not know the project structure for DNN - the MVC project template should have a Views folder at the site root, if DNN follows that at all. If not, you probably don't have to worry about it. As for the `LCE.DNN.Modules.StoreLocator` module, if it's not a built-in part of DNN, you'll want to figure out what version of `System.Web.Mvc` it references. If it's [this](http://www.dnnsoftware.com/community-blog/cid/135155/dotnetnuke-store-locator) module, it's pretty old, so I would assume it's the culprit. – Tieson T. Oct 05 '16 at 17:24
  • Do you want me to update System.web.Razor package through Nuget console? – Jaggi Oct 05 '16 at 17:32
  • I doubt that would help at all, assuming I am correct in which module you are trying to add. – Tieson T. Oct 05 '16 at 17:39
  • Yeah, Actually that doesn't work. – Jaggi Oct 05 '16 at 17:44

2 Answers2

0

It looks like you had a few attempts to uninstall, upgrade or install the various ASP.NET components and some failures occurred. The duplicates in your list are only different based on the casing of the PublicKeyToken which might suggest you used different versions of packages or NuGets between attempts.

I would do the following to try and resolve the situation:

  • Back everything up.
  • Uninstall all the packages via NuGet. Keep an eye out for errors.
  • Manually check your .csproj files and remove any references NuGet may not have removed
  • Repeat for your packages.config files.
  • In your web.config remove all the dependentAssembly entries.
  • Reinstall the correct versions of the correct packages into the correct projects.
  • Clear your ASP.NET temporary files
  • Do a clean build.

I have seen this situation happen before, and for me, it occurred when our internal NuGet server had issues of some sort, though it could happen for nuget.org as well.

Another possibility is that something you reference references a version of Razor different from what you reference directly (I'm guessing DNN from your post). You'll have to hunt that one down and upgrade it if possible or somehow standardize on a single version.

Regardless, I would still do the above steps.

Community
  • 1
  • 1
Kit
  • 20,354
  • 4
  • 60
  • 103
0

Try issuing the following command at the nuget console.

Install-Package Microsoft.AspNet.Razor -Version 2.0.30506

If it says its installed then run:

Update-Package Microsoft.AspNet.Razor
Joe Healy
  • 5,769
  • 3
  • 38
  • 56