0

<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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

That was the trick. Funny how I no longer care about why its not working in the web.config! Thanks for the help Simon.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.