I am adding a control library reference from Infragistics to use their controls in my ASP .NET MVC 3 Razor views. I have added the dll as a reference to the project already.


My controllers can access the namespace fine if I add a using Infragistics.Web.Mvc at the top of the file.
There are two ways to tell the views to include a namespace. The first is to put @using Infragistics.Web.Mvc at the top of your view. However if I try that, I get the following error:
The type or namespace name ‘Infragistics’ could not be found (are you
missing a using directive or an assembly reference?)
The second is to add a call to the namespace in the pages part of the view Web.config like this:
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=ABCABCABCABCABC" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
Other namespaces...
<add namespace="Infragistics.Web.Mvc"/>
</namespaces>
</pages>
</system.web.webPages.razor>
however this doesn’t work either.
The only way I could get it to work was by adding the following line into the root Web.config file:
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
...
<add assembly="Infragistics.Web.Mvc, Version=3.11.1.2010, Culture=neutral, PublicKeyToken=blahblahblah" />
</assemblies>
</compilation>
On some further investigation regarding Web.config, I found that by including that line it tells the compiler to use that resource when compiling the ASP .NET resources. I had to use SN.exe to find the PublicKeyToken.
What am I doing wrong?
I’m not sure how the Infragistics installation works or how you’re running your website, but you may need to tell Visual Studio to copy the dll on build so it’s included with the web project. It’s worth checking before exploring too many other options.
Here is an example