3

I'm getting this error when I try to use access an ASP.NET MVC3 application using the Spark View Engine published to my local IIS 7 server. I've looked at this answer and have already followed that advice, but I still get problems. I also tried changing the Copy Local setting to true for the Microsoft.Web.Mvc DLL. I never get this error with the Visual Studio debug server. Republishing sometimes makes the error go away, but it comes back.

Where should I start looking to get rid of this problem?

Thanks!

<!-- At the end of my Web.config: -->
<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>

edit: For clarity, the IIS server that I'm trying to deploy to is on my development machine.

edit: My _global.spark looks something like this:

<use namespace="System.Collections.Generic"/>
<use namespace="System.Web.Mvc.Html"/>
<use namespace="System.Web.Mvc"/>
<use namespace="System" />
<use namespace="System.Linq" />
<use namespace="Namespace.For.Some.Code" />
<use namespace="Namespace.For.Some.More.Code" />
<use namespace="Namespace.For.Yet.Some.More.Code" />
<use namespace="Microsoft.Web.Mvc" />
<use namespace="Namespace.For.Still.More.Code" />

<!-- Added after suggested answer -->
<use assembly="Microsoft.Web.Mvc"/>

<global type="string" Title="'title of my app'" />
<global type="SomeDomainObject" SomeVariable="Utilities.ApplicationUtilities.GetSomeDomainObject" />
Community
  • 1
  • 1
Becca Dee
  • 1,530
  • 1
  • 24
  • 51
  • Is MVC3 installed on your server? If not install it manually or include the relevant dll's via a BIN deploy. – Jesse Jun 15 '12 at 17:13
  • Thanks for the reply, Jesse. This is using the same machine I'm doing the development on, and, like I said, it sometimes works and sometimes doesn't. Do I need to install MVC3 into IIS specifically ? – Becca Dee Jun 15 '12 at 18:34
  • Ahh, my apologies. I miss read part of you question. Since this is already your local machine then disregard my comment. – Jesse Jun 15 '12 at 18:37
  • That's alright. I appreciate the response! – Becca Dee Jun 15 '12 at 19:22

1 Answers1

1

Have you referenced MVC from your /Shared/_global.spark file?

You can see the details in this answer

Alternatively you can add the namespaces to your SparkSettings when you register the ViewEngine. This is what mine looks like:

var settings = new SparkSettings()
 .SetDebug(true)
 .SetAutomaticEncoding(true)
 .AddAssembly("Web")
 .AddNamespace("Web.Model")
 .AddNamespace("System.Collections.Generic")
 .AddNamespace("System.Linq")
 .AddNamespace("System.Web.Mvc")
 .AddNamespace("System.Web.Mvc.Html");

Hope that helps,
Rob

Community
  • 1
  • 1
RobertTheGrey
  • 8,645
  • 5
  • 32
  • 45
  • I made the change posted above, and that *seems* to be working. Since the problem has been intermittent, I'll see how it goes for the day. The line I added is ``, and I added directly to the _global.spark file in my IIS directory. – Becca Dee Jun 20 '12 at 14:18