Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am currently testing Umbraco 7.3
The following line causes an error which didnt happen in previous versions:
ContentService c = new ContentService();
The error is:
'Umbraco.Core.Services.ContentService' does not contain a constructor that takes 0 arguments
Anyone know why this no longer works in 7.3.
the Public empty constructor for ContentService appears to have gone in 7.3 the only constructor is now
which means you need a lot of other stuff to call it
However i think calling ContentService this way is really only used when runing through the tests.
if you want to get to a version of content service for the current umbraco instance you should call
var contentService = ApplicationContext.Current.Services.ContentService;
You will then have an instance of content service you can do anything you need to with.
Thank you Kevin, all sorted now.
You the man!!!
Just came across this after moving a site to 7.3.0, thanks for the solution Kevin!
Spot on for me too; although I wish I had seen this about 4 hours ago!
I'm still unclear how to call ContentService from, say, a Partial View Macro, where I'd previously had just:
var cs = new ContentService();
I've tried the full ApplicationContext.Current.Services.ContentService line but that throws errors also (cannot be accessed with an Instance reference).
Do you have the @using Umbraco.Core set?
Take a look at how I've been using the CS in my instance here if that helps?
Wow, it 's really worked on latest versions of Umbraco onward 7.3.X.
Thanks a lot Kevin.
I forund this it helped me if others having trouble
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted