Razor Assistant in MVC 3 RC

I get an error when using razor helpers in an MVC 3 project (put the cshtml file in app_code). It looks like the generated code is using the wrong assembly reference.

Using WebMatrix.Data
using WebMatrix.WebData;

The compiler says:

CS0246: Could not find the name of the type or namespace "WebMatrix" (are you missing the using directive or assembly references?)

Entering them in the GAC has not changed anything. Don't I understand? Or is this a mistake? Any ideas?

+7
asp.net-mvc razor helpers
source share
6 answers

You need to add the link to the DLL in Web.config.

+5
source share

mbr, we are aware of the problem and planning its solution for RTM. You could either add links to WebMatrix assemblies as suggested by SLaks, or (and I think it’s better) just add these 2 namespaces to your project by adding the following code:

namespace WebMatrix.Data { internal class Ignore { } } namespace WebMatrix.WebData { internal class Ignore { } } 
+5
source share

I ran into this problem and helped with this answer. And then I ran into another problem when I started using Telerik, this answer: Razor HtmlHelper Extensions (or other namespaces for views) not found pointed me to another solution for this problem.

+2
source share

Put the code in the file (I chose Fixup.cs), as in the App_Code directory:

 using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace WebMatrix.Data { internal class Ignore { } } namespace WebMatrix.WebData { internal class Ignore { } } 
0
source share

you just need to add WebMatrix.WebData.dll to your links.

0
source share

Typically, DLL file references can be complex if you don’t know the exact location of the DLL files or if the DLL files have any dependencies. Use the package manager to automatically bind links for you.

Just open the tools-> Library Package Manager-> Package Manager Console in Visual Studio and in the Package Manager Console Type "Install-Package WebMatrix.Data" and you're done. Link to this link

http://www.nuget.org/packages/WebMatrix.Data/

0
source share