Eric J.
Eric J.

Reputation: 150108

Cshtml Unable to Resolve Reference

I'm adding Microsoft.Web.Optimization to an MVC 4 Beta project.

My _Layout.cshtml:

<script src="@Microsoft.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Scripts/Framework/js", true)"></script>

complains

Error 1 The type or namespace name 'Optimization' does not exist in the namespace 'Microsoft.Web' (are you missing an assembly reference?)

However, any .cs file in the project can resolve that type (for example, a controller).

Do I need to do something to inform a .cshtml page about the newly added reference?

Upvotes: 12

Views: 9911

Answers (2)

Russell Horwood
Russell Horwood

Reputation: 1044

I started getting this error all of a sudden, the usual trick of restarting IIS didn't work, but restarting Visual Studio did.

Upvotes: 0

Eric J.
Eric J.

Reputation: 150108

Turns out NuGet offered me and old version, 0.1. I'm not sure why that caused this issue, but removing that reference and adding 1.0.0-Pre through NuGet resolved the issue

http://www.nuget.org/packages/Microsoft.Web.Optimization

Note that the namespace has changed to System.Web.Optimization in this release.

Upvotes: 15

Related Questions