Killdashnine
Killdashnine

Reputation: 5

Compilation Error in ASP.NET mvc3

<div class="dateAdded">Article submitted @article.DateAdded.ToRelativeDateStringUtc()</div>

Compiler Error Message: CS1061: 'System.DateTime' does not contain a definition for 'ToRelativeDateStringUtc' and no extension method 'ToRelativeDateStringUtc' accepting a first argument of type 'System.DateTime' could be found (are you missing a using directive or an assembly reference?)

Here is where my error is occurring. I have a class that contains ToRelativeDateStringUtc() included in my program. Is this a MS class that I have to import? I do not see it listed anywhere in the .net reference list. I'm sure its something simple, does anyone have any ideas?

I have already added the folder to my webconfig that includes the class, which contains the method the program is "missing". So its not missing it... I just dont know what else to do from here.

Upvotes: 0

Views: 79

Answers (1)

Simon Whitehead
Simon Whitehead

Reputation: 65087

There are several things you could try.

Firstly, you can try the using directive inside the view you use this in:

@using Your.Namespace.Where.Extension.Class.Is.Located

Secondly, the web.config you've added the namespace to is probably the global one. If this view is inside an Area.. try putting the namespace into the web.config that is inside that particular area.

The first one will work regardless.

Upvotes: 1

Related Questions