"does not contain a definition ... and does not have an extension method .."

I had a problem due to which I cannot use the object method due to this error:

Does not contain a definition ... and no extension method ...

This is very related to this question . I am doing what is given as the answer in this question, but I am still getting this error.

namespace MyProject.ViewModel
{
    public class NetworkHealthViewModel : ViewModelBase
    {
        private IDataService _dataService;
        public ObservableCollection<NetworkBandwidthModel> NbicNetworkBandwidth
        public ObservableCollection<NetworkPortalStatusModel> NbicNetworkPortalStatus

        public NetworkHealthViewModel()
        {
            _dataService = new DataServiceNetworkHealth();
            NbicNetworkBandwidth       = new ObservableCollection<NetworkBandwidthModel>();
            NbicNetworkPortalStatus    = new ObservableCollection<NetworkPortalStatusModel>();
            _dataService.LoadChartItems(NetworkBandwidthLoaded, NetworkBandwidthLoadedFailed);
            _dataService.LoadPortalStatus(NetworkPortalStatusLoaded, NetworkPortalStatusLoadedFailed);
         }

The error lies with LoadPortalStatus (). LoadChartItems () is excellent. NetworkBandwidthLoaded and NetworkPortalStatusLoaded are delegates.

NetworkPortalStatusLoaded is laid out almost the same as NetworkBandwidthLoaded:

private void NetworkPortalStatusLoaded(IEnumerable<ChartModel> portalStatItems) 
{
    NbicNetworkPortalStatus.Clear();

    var networkPortalItems = from item in portalStatItems
                             where ((NetworkPortalStatusModel)item).Unit == "Portal"
                             select item;

    foreach (var item in networkPortalItems)
    {
        NbicNetworkPortalStatus.Add((NetworkPortalStatusModel)item);
    }

    Message = "Network Portal details loaded";
}

My DataServiceNetworkHealth class is defined as:

namespace MyProject.DataServices
{
    public class DataServiceNetworkHealth : IDataService
    {
        private Action<IEnumerable<ChartModel>> _delagateSuccess;
        private Action<Exception> _delagateFail;
        private String _portalHtmlResponse;

        public void LoadChartItems(Action<IEnumerable<ChartModel>> success, Action<Exception> fail)
        {
          ....
        }

        public void LoadPortalStatus(Action<IEnumerable<ChartModel>> success, Action<Exception> fail)
        {
          ....
        }
    }
}

LoadChartItems() IDataService, LoadPortalStatus - . , , . DataServiceX, LoadPortalStatus.

, , , .:-) !

+3
4

_dataService IDataService, , , ( ). , LoadPortalStatus , _dataService.

: . List<int> :

List<int> i = new List<int>();

List<T>() Object. ,

IEnumerable<int> i = new List<int>();

i GetEnumerator, IEnumerable<T> , Object.

System.Linq, , IEnumerable<T>.

i , .

+2

LoadPortalStatus ( ), .

:

private IDataService _dataService;

, _dataService, IDataService ( ), .

, :

1) _dataService LoadPortalStatus. 2) LoadPortalStatus IDataService. 3) IDataService, LoadPortalStatus

, , , , 1 2.

0

, , , LoadPortalStatus(). 2 x LoadChartItems().

Error copying folders?

Can you also publish the interface code?

0
source

It may be too obvious, but you can get this error because you really have no method LoadPortalStatusin your code?

You have several methods LoadChartItemswith identical signatures - is it possible that one of them should be a method LoadPortalStatus()?

public void LoadChartItems(Action<IEnumerable<ChartModel>> success, Action<Exception> fail)
{
    ....
}

//Same signature as above - is this supposed to implement LoadPortalStatus??
public void LoadChartItems(Action<IEnumerable<ChartModel>> success, Action<Exception> fail)
{
    ....
}
0
source

All Articles