1

We have a issue with using Linq expressions in our MVC views. Visual studio / resharper keeps asking to import System.Data.Linq into the view. When I click on it, the import fails. I have added the following line into the web.config:

<assemblies>
            <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
            <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        </assemblies>

So this should mean that visual studio / resharper should be able to allow us to use it in the views, but it shows it as an error. When we run the code it works fine, it is just annoying to see errors while developing. So the question is : How can I fix resharper / visual studio showing the error and allowing auto complete?

EDIT, I have tried <%@ Import Namespace="System.Data.Linq" %> which doesn't help.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Steve
  • 50,173
  • 4
  • 32
  • 41

2 Answers2

1

The reason that I think this issue was fixed was due to the addins that I had installed. I had a version of resharper installed and I removed it and re-installed it on the machine. But it may have been upgrading the project to .Net 4. Either one of those two actions seems to solve this problem.

Steve
  • 50,173
  • 4
  • 32
  • 41
0

Have you tried adding the using directive to the top of the view

Not sure what view engine you're using but it might look like this

<%@ Import Namespace="System.XML.Linq" %>

or 

@using System.XML.Linq;

I've not tested this but it kinda rings a bell... Let me know if its any good to you...