Reputation: 333
I get an error when using razor helpers in an MVC 3 project (did put the cshtml file in app_code). Looks like the generated code is using a wrong assembly reference.
using WebMatrix.Data;
using WebMatrix.WebData;
Compiler says:
CS0246: The type or namespace name 'WebMatrix' could not be found (are you missing a using directive or an assembly reference?)
Putting them into GAC did not change anything. Am I not getting it? Or is this a bug? Any ideas?
Upvotes: 7
Views: 6960
Reputation:
Referencing the DLL files yourself might be tricky if you don't know the exact location of the DLL Files or if the DLL files have any dependencies. Use Package Manager to auto-reference dependencies for you.
Just Simply Open Tools->Library Package Manager->Package Manager Console in Visual Studio & in Package Manager Console Type "Install-Package WebMatrix.Data" and you are done. Refer this Link
http://www.nuget.org/packages/WebMatrix.Data/
Upvotes: 0
Reputation: 101
Put the code in a file (I chose Fixup.cs) like so 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 { } }
Upvotes: 0
Reputation: 53191
mbr, we are aware of the issue and plan on addressing it for RTM. You could either add references to the WebMatrix assemblies like SLaks suggested or (and I think this is better) simply add those 2 namespaces to your project by adding the following code:
namespace WebMatrix.Data { internal class Ignore { } }
namespace WebMatrix.WebData { internal class Ignore { } }
Upvotes: 5
Reputation: 1732
I ran into this problem, and was helped by this answer. And then I ran into another problem when I started trying to use Telerik, this answer: Razor HtmlHelper Extensions (or other namespaces for views) Not Found pointed me towards another solution for this problem.
Upvotes: 2