Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8398929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:10:08+00:00 2026-06-09T21:10:08+00:00

I need to return a custom object in a WCF service to a calling

  • 0

I need to return a custom object in a WCF service to a calling asp.net application.
I’m getting the error
Cannot implicitly convert type ‘test.ServiceReference1.ReturnClass’ to ‘test.ReturnClass’
here is my calling function in asp.net (error im bold)
Can i return my object and how?

// Get the drive list from the client machine
ServiceReference1.JobsClient Client = new ServiceReference1.JobsClient();
Client.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://" + DropDownListSystems.SelectedValue + ":8732/test/");
ReturnClass Drive_Result = new ReturnClass(); // Declare an instance of the return object that will contain all the results
**Drive_Result = Client.FindDrives();**

here is my WCF Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Collections;
namespace WCFJobsLibrary
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IJobs" in both code and config file together.
    [ServiceContract]
    public interface IJobs
    {
         //Directoy Manager
         [OperationContract]
        ReturnClass FindDrives();
         //Directoy Manager
         [OperationContract]
         ReturnClass FindSubfolders(String Folder_To_Search);
         //Directoy Manager
         [OperationContract]
         ReturnClass FindSubFiles(String Folder_To_Search);


    }
}

//Directoy Manager
public ReturnClass FindDrives()
{

    try
    {
        DriveInfo[] allDrives = DriveInfo.GetDrives();
        ArrayList Drives = new ArrayList();
        foreach (DriveInfo d in allDrives)
        {
            Drives.Add(d.Name);
        }
        return new ReturnClass(1, String.Empty, String.Empty, Drives, null, null);
    }
    catch (Exception ex)
    {
        return new ReturnClass(-1, ex.Message.ToString(), ex.InnerException.ToString(), null, null, null);
    }

}



public class ReturnClass
{
    //private members
    private int _errorCode;
    private string _errorMessage;
    private string _exMessage;
    private ArrayList _drives;
    private string[] _folders;
    private string[] _filePaths;


    #region Constructors

    //constructor 1
    public ReturnClass()
    {

    }

    //constructor 2
    public ReturnClass(int iErr, string sErrMsg, string ExMsg, ArrayList arrDrives, string[] sfolders, string[] sFilePaths)
    {
        ErrorCode = iErr;
        ErrorMessage = sErrMsg;
        ExMessage = ExMsg;
        Drives = arrDrives;
        Folders = sfolders;
        FilePaths = sFilePaths;
    }

    #endregion

    #region methods

    //Error Code
    public int ErrorCode
    {
        get { return this._errorCode; }
        set { this._errorCode = value; }
    }

    //error message
    public string ErrorMessage
    {
        get { return this._errorMessage; }
        set { this._errorMessage = value; }
    }

    //exception message
    public string ExMessage
    {
        get { return this._exMessage; }
        set { this._exMessage = value; }
    }

    //drives
    public ArrayList Drives
    {
        get { return this._drives; }
        set { this._drives = value; }
    }

    //folders
    public string[] Folders
    {
        get { return this._folders; }
        set { this._folders = value; }
    }

    //File Paths
    public string[] FilePaths
    {
        get { return this._filePaths; }
        set { this._filePaths = value; }
    }

    #endregion

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:10:10+00:00Added an answer on June 9, 2026 at 9:10 pm

    You should just declare Drive_Result as test.ServiceReference1.ReturnClass, not ReturnClass (there’s something messed up with your namespaces).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using WCF service in my application. I need to return a custom object
I need to create a custom route for a WCF data service that contains
I need to return two values at a time, so I have: class IterableObject(object):
I have a WCF service where I am trying to return a List (where
In my WCF project I need to use custom headers in responses so I
I have a theoretical question. I have a WCF web service that need to
For a very custom calendar control, I need to have a week object and
I need to return an a generic list in the correct order for my
i need to return a JSON with this format: {answers: [{id: 93, value:Ahstron}, {id=94,
I need to return a list of counties, but I need to filter out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.