Using the following code based on the docs in a .core project I get two errors which I can't fathom out:-
An object reference is required for the non-static field, method, or property 'ImportProperties._logger'
'ILogger' has no applicable method named 'Info' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.
using Umbraco.Core;
using Umbraco.Core.Logging;
namespace BSL8.Core.Services {
public class ImportProperties {
Try taking "static" off of the GetPropertyList method.
_logger isn't set if you call that method as you aren't instantiating the class to get ILogger passed in.
That cleared the 1st error, still leaving the 2nd error and generated a new error on the API that calls the method which is:-
namespace BSL8.Core.Controllers.APIControllers
{
public class PropertyImportController : UmbracoApiController
{
[HttpGet]
public IHttpActionResult GetAllProperties()
{
ImportProperties.GetPropertyList();
// Gets a list of properties then iterates through it to update each property that's out of date.
return Ok();
}
}
}
The error being (as expected) An object reference is required for the non-static field, method, or property 'ImportProperties.GetPropertyList()
So ILogger still doesn't have an "Info" method. Maybe it's being overwritten by another ILogger in one of the other usings:-
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Web;
using Umbraco.Core.Logging;
using Newtonsoft.Json.Linq;
using System;
using System.Net;
using System.Text.RegularExpressions;
using System.IO;
using System.Linq;
using System.Net.Mail;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Composing;
using System.Collections.Generic;
Logging Namespace Issue
Umb V8.6.1
Using the following code based on the docs in a .core project I get two errors which I can't fathom out:-
'ILogger' has no applicable method named 'Info' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.
}
Any clues as to why this doesn't work would be appreciated.
/ Craig
Hi Craig,
Try taking "static" off of the
GetPropertyList
method. _logger isn't set if you call that method as you aren't instantiating the class to get ILogger passed in.Thanks,
Nik
Thanks Nik,
That cleared the 1st error, still leaving the 2nd error and generated a new error on the API that calls the method which is:-
The error being (as expected)
An object reference is required for the non-static field, method, or property 'ImportProperties.GetPropertyList()
So ILogger still doesn't have an "Info" method. Maybe it's being overwritten by another ILogger in one of the other usings:-
is working on a reply...