views:

24

answers:

1

I'm trying to get Nhaml working for an ASP.NET MVC 2 project. The backend of the project is Mongo DB, using the NoRM driver. NoRM specifies some custom types, particularly ObjectID as a reference to Mongo's unique _id column.

I've got the Nhaml views compiling and outputting data from a strongly typed model, but it's choking on the ObjectID type written as such:

%td= Html.ActionLink("Update", "Update", new { id=Model._id })

Specifically, the error message is:

c:\Windows\Temp\a7lwemtp.0.cs(83,9) : error CS0012: The type 'Norm.ObjectId' is defined in an assembly that is not referenced. You must add a reference to assembly 'Norm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

...which seems fairly straightforward, except I still get the same error message after adding the Norm assembly reference to the Nhaml configuration part of my web.config file:

<nhaml autoRecompile="true" templateCompiler="CSharp3" encodeHtml="false" useTabs="false" indentSize="2">
  <assemblies>
    <add assembly="Norm" Version="1.0.0.0" Culture="neutral" PublicKeyToken="null"/>
    <add assembly="MyApp"/>
  </assemblies>
  <namespaces>
    <add namespace="MyApp"/>
    <add namespace="MyApp.Controllers"/>
    <add namespace="MyApp.Models"/>
    <add namespace="Norm"/>
    <add namespace="Norm.BSON.DbTypes"/>
  </namespaces>
</nhaml>

I rather expected that to fix the problem. Am I missing something obvious, or completely misunderstanding the assembly reference that Nhaml is looking for?

A: 

Just in case you are missing something obvious or completely misunderstanding the assembly reference thang...

CS0012 is the C# compiler asking for a reference to the dll or project that contains Norm.ObjectId. Adding elements to a config file won't fix it, you need to make sure that your MVC 2 project has a reference to either the built NoRM dll or the NoRM project if you've added the source code to your solution.

http://msdn.microsoft.com/en-us/library/x0dz51e1%28VS.90%29.aspx

panamack
Then I am confused, because I have the NoRM dll referenced in VS. And the NoRM driver works in the rest of my project. Hmm.
DanielMason