Click here to Skip to main content
15,879,096 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am facing an issue wherein on the page following issue is coming:-

Request Failed. Try Again.

When I debugged the code then I found that the issue is actually coming due to this class file not found:- GanttProvider the actual error in the code is showing that:
The type or namespace name 'GanttProvider' could not be found (are you missing a using directive or an assembly reference?)

ASP.NET
<%@ WebService Language="C#" Class="GanttService" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Services;
using System.Web.Services;
using System.Web.SessionState;
//using Telerik.Web.UI
using Telerik.Web.UI.Gantt;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class GanttService : System.Web.Services.WebService, IRequiresSessionState
{
    private WebServiceController _controller;

    public WebServiceController Controller
    {
        get
        {
            if (_controller == null)
            {
                _controller = new WebServiceController(new GanttProvider());
            }

            return _controller;
        }
    }
    [WebMethod(EnableSession = true)]
    public IEnumerable<CustomTaskData> GetTasks()
    {
        var ddd = Controller.GetTasks<CustomTaskData>();
        var provider = new GanttProvider();
        foreach (var item in ddd)
        {
            //item.Dependency = provider.GetSuccessorByTaskID((int)item.ID);
            item.Dependency = provider.GetPredecessorByTaskID((int)item.ID);
        }

        return ddd;
    }
    [WebMethod(EnableSession = true)]
    public IEnumerable<CustomTaskData> InsertTasks(IEnumerable<CustomTaskData> models)
    {
        var plannerRefId = HttpContext.Current.Session["GanttPlannerRefId"] != null ? Convert.ToInt32(HttpContext.Current.Session["GanttPlannerRefId"]) : 0;
        var plannerId = HttpContext.Current.Session["GanttPlannerID"] != null ? Convert.ToInt32(HttpContext.Current.Session["GanttPlannerID"]) : 0;
        var plannerType = HttpContext.Current.Session["GanttPlannerType"] != null ? HttpContext.Current.Session["GanttPlannerType"].ToString() : "project";
        if (plannerType.Equals("vendor", StringComparison.InvariantCultureIgnoreCase))
        {
            foreach (var item in models)
            {
                item.RootVendorID = plannerRefId;
                item.PlannerID = plannerId;
            }
        }else
        {
            foreach (var item in models)
            {
                item.ProjectID = plannerRefId;
                item.PlannerID = plannerId;
            }
        }
        return Controller.InsertTasks<CustomTaskData>(models);
    }
    [WebMethod(EnableSession = true)]
    public IEnumerable<CustomTaskData> UpdateTasks(IEnumerable<CustomTaskData> models)
    {
        var plannerRefId = HttpContext.Current.Session["GanttPlannerRefId"] != null ? Convert.ToInt32(HttpContext.Current.Session["GanttPlannerRefId"]) : 0;
        var plannerId = HttpContext.Current.Session["GanttPlannerID"] != null ? Convert.ToInt32(HttpContext.Current.Session["GanttPlannerID"]) : 0;
        var plannerType = HttpContext.Current.Session["GanttPlannerType"] != null ? HttpContext.Current.Session["GanttPlannerType"].ToString() : "project";
        if (plannerType.Equals("vendor", StringComparison.InvariantCultureIgnoreCase))
        {
            foreach (var item in models)
            {
                item.RootVendorID = plannerRefId;
                item.PlannerID = plannerId;
            }
        }else
        {
            foreach (var item in models)
            {
                item.ProjectID = plannerRefId;
                item.PlannerID = plannerId;
            }
        }
        return Controller.UpdateTasks<CustomTaskData>(models);
    }
    [WebMethod(EnableSession = true)]
    public IEnumerable<CustomTaskData> DeleteTasks(IEnumerable<CustomTaskData> models)
    {
        return Controller.DeleteTasks<CustomTaskData>(models);
    }
    [WebMethod(EnableSession = true)]
    public IEnumerable<DependencyData> GetDependencies()
    {
        return Controller.GetDependencies();
    }
    [WebMethod(EnableSession = true)]
    public IEnumerable<DependencyData> InsertDependencies(IEnumerable<DependencyData> models)
    {
        return Controller.InsertDependencies(models);
    }
    [WebMethod(EnableSession = true)]
    public IEnumerable<DependencyData> DeleteDependencies(IEnumerable<DependencyData> models)
    {
        return Controller.DeleteDependencies(models);
    }

    [WebMethod(EnableSession = true)]
    public IEnumerable<Telerik.Web.UI.Gantt.ResourceData> GetResources()
    {
        return Controller.GetResources();
    }

    [WebMethod(EnableSession = true)]
    public IEnumerable<AssignmentData> GetAssignments()
    {
        return Controller.GetAssignments();
    }
    [WebMethod(EnableSession = true)]
    public IEnumerable<AssignmentData> InsertAssignments(IEnumerable<AssignmentData> models)
    {
        return Controller.InsertAssignments(models);
    }
    [WebMethod(EnableSession = true)]
    public IEnumerable<AssignmentData> UpdateAssignments(IEnumerable<AssignmentData> models)
    {
        return Controller.UpdateAssignments(models);
    }
    [WebMethod(EnableSession = true)]
    public IEnumerable<AssignmentData> DeleteAssignments(IEnumerable<AssignmentData> models)
    {
        return Controller.DeleteAssignments(models);
    }
}


[System.Runtime.Serialization.DataContract]
public class CustomTaskData : TaskData
{
    [System.Runtime.Serialization.DataMember]
    public string Description
    {
        get;
        set;
    }

    [System.Runtime.Serialization.DataMember]
    public int? ProjectID
    {
        get;
        set;
    }
    [System.Runtime.Serialization.DataMember]
    public int? PlannerID
    {
        get;
        set;
    }

    [System.Runtime.Serialization.DataMember]
    public string CusTaskType
    {
        get;
        set;
    }

    [System.Runtime.Serialization.DataMember]
    public double? CusDuration
    {
        get;
        set;
    }
    [System.Runtime.Serialization.DataMember]
    public double? CusActualHour
    {
        get;
        set;
    }
    [System.Runtime.Serialization.DataMember]
    public int? VendorID
    {
        get;
        set;
    }

    [System.Runtime.Serialization.DataMember]
    public string Vendor
    {
        get;
        set;
    }
    [System.Runtime.Serialization.DataMember]
    public int? RootVendorID
    {
        get;
        set;
    }

    [System.Runtime.Serialization.DataMember]
    public string RootVendorName
    {
        get;
        set;
    }
    [System.Runtime.Serialization.DataMember]
    public string ProjectName
    {
        get;
        set;
    }
    [System.Runtime.Serialization.DataMember]
    public string Dependency
    {
        get;
        set;
    }

    [System.Runtime.Serialization.DataMember]
    public int? PlannerTaskID
    {
        get;
        set;
    }
    [System.Runtime.Serialization.DataMember]
    public int? ItemRefID
    {
        get;
        set;
    }
    public override void CopyFrom(ITask srcTask)
    {
        base.CopyFrom(srcTask);

        Description = ((CustomTaskData)srcTask).Description;
        ProjectID = ((CustomTaskData)srcTask).ProjectID;
        PlannerID = ((CustomTaskData)srcTask).PlannerID;
        CusTaskType = ((CustomTaskData)srcTask).CusTaskType;
        CusDuration = ((CustomTaskData)srcTask).CusDuration;
        CusActualHour = ((CustomTaskData)srcTask).CusActualHour;
        VendorID = ((CustomTaskData)srcTask).VendorID;
        Vendor = ((CustomTaskData)srcTask).Vendor;
        RootVendorID = ((CustomTaskData)srcTask).RootVendorID;
        RootVendorName = ((CustomTaskData)srcTask).RootVendorName;
        ProjectName = ((CustomTaskData)srcTask).ProjectName;
        PlannerTaskID = ((CustomTaskData)srcTask).PlannerTaskID;
        ItemRefID = ((CustomTaskData)srcTask).ItemRefID;
        Dependency = ((CustomTaskData)srcTask).Dependency;
    }

    public override void CopyTo(ITask destTask)
    {
        base.CopyTo(destTask);

        ((CustomTaskData)destTask).Description = Description;
        ((CustomTaskData)destTask).ProjectID = ProjectID;
        ((CustomTaskData)destTask).PlannerID = PlannerID;
        ((CustomTaskData)destTask).CusTaskType = CusTaskType;
        ((CustomTaskData)destTask).CusDuration = CusDuration;
        ((CustomTaskData)destTask).CusActualHour = CusActualHour;
        ((CustomTaskData)destTask).VendorID = VendorID;
        ((CustomTaskData)destTask).Vendor = Vendor;
        ((CustomTaskData)destTask).RootVendorID = RootVendorID;
        ((CustomTaskData)destTask).RootVendorName = RootVendorName;
        ((CustomTaskData)destTask).ProjectName = ProjectName;
        ((CustomTaskData)destTask).PlannerTaskID = PlannerTaskID;
        ((CustomTaskData)destTask).ItemRefID = ItemRefID;
        ((CustomTaskData)destTask).Dependency = Dependency;
    }
}


I am facing issue where I am trying to pass the object of GanntProvider class in WebServiceController constructor. It's an .ASMX file.

Kindly help me resolve this.

Thanks
Varun

What I have tried:

I tried searching on google but couldn't found any thing related to GanttProvider.
Posted
Updated 13-Mar-23 18:10pm
v3
Comments
peterkmx 13-Mar-23 12:07pm    
This makes me curious which code are you debugging ... From GitHub or another place ?
Best regards
Varun Sareen 13-Mar-23 23:51pm    
Updated the question.

The error is pretty much self explanatory: your code will not compile becuas ethe class or namespace "GanttProvider" cannot be found.

Start by looking at the error message carefully - it will give you which file and line the problem was found in (this may help you understand the details it gives you: How to Write Code to Solve a Problem, A Beginner's Guide Part 2: Syntax Errors[^]

When you know exactly what it is looking for, then add the appropriate using statement(s) to each source file that references it, and / or add the requires reference and make sure the assembly is installed on the server, or available in the folder.
 
Share this answer
 
Comments
Varun Sareen 13-Mar-23 8:32am    
Hi,

I understand that GanttProvider reference is not found that is why the issue is coming. My query is not able to find the DLL which will help me resolve the issue. I searched on google but couldn't succeed.

Thanks
OriginalGriff 13-Mar-23 9:40am    
And you expect us to be able to find it, without any access to your systems, or even any idea what assembly might contain a class the source of which we have no clue?
Varun Sareen 13-Mar-23 23:44pm    
It is not that what I meant. My bad for not adding much details. I have updated my question.
Not enough information. The error is telling you you're trying to use a class that is not defined in your code anywhere.

So what library are you using that should define the GanttProvider class? You have to set a Reference to that library.
 
Share this answer
 
Ah, this is a Telerik control[^] question.

The best place to ask this question is in the Telerik Help Forums: The Built From Developers .NET & JavaScript Community | Telerik Forums[^] - make sure that you choose the correct library type before asking your question. eg: if it is a WPF question, select the UI for WPF Forum[^], then tag the question with the correct tag. eg: GanttView[^].
 
Share this answer
 
Comments
Varun Sareen 14-Mar-23 1:24am    
Thanks Graeme. Appreciate your effort.

Regards
Varun
Graeme_Grant 14-Mar-23 1:35am    
All good. They are usually very good at supporting their controls.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900