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

  • SEARCH
  • Home
  • 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 1060445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:19:40+00:00 2026-05-16T18:19:40+00:00

I have the following class [DataContract] public class A { private List<B> b= new

  • 0

I have the following class

[DataContract]
public class A
{
    private List<B> b= new List<B>();

    public float getSum()
    {
        float sum= 0;

        foreach (B b1 in b)
        {
            sum+= b1.sum;
        }

        return sum;
    }

    [DataMember]
    public int B
    {
        get { return b; }
        set { b = value; }
    }

The function getSum() is domain specific function.
I have wcf service hosted in IIS and wcf client.

In the client I like to use the class A and to call the function getSum().
The function needs to be local call, not remote.

I like to use it this way:

A a = proxy.getA(101);

var1 = a.getSum();

A a1 = new A();
a1.setSomething
proxy.Insert(a1);

How can I do this with wcf ?

  • 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-05-16T18:19:41+00:00Added an answer on May 16, 2026 at 6:19 pm

    The only way to achieve this is to use the same assembly containing this class on the client instead of generating a proxy. So put this class into a separate assembly that you will share between the client and the server. Obviously if your client is not .NET this won’t be possible.


    To reuse types from a given assembly you could use the /reference:<file path> switch when generating your proxy class instead of importing them from the WSDL of the web service and thus losing the getSum() (which by the way should start with a capital letter in order to follow good coding practices):

    svcutil.exe /reference:AssemblyThatContainsTheClassA.dll http://example.com/test.svc?wsdl
    

    or if you are using the Add Service Reference... dialog in Visual Studio:

    alt text

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

Sidebar

Related Questions

I have the following WCF DataContract: [DataContract] public class Occupant { private string _Name;
I have following class public class ButtonChange { private int _buttonState; public void SetButtonState(int
Just imagine you have the following class [DataContract] public class NamedList { [DataMember] public
I have the following DTO definition:- [DataContract] public class AddProductDTO { [DataMember] public string
I have the following model: [DataContract] public class MessageHeader { private Guid? messageId; public
I have the following: [DataContract] public class Foo { [DataMember(EmitDefaultValue = true) public bool
Basically if I have the following: [DataContract] public class Foo { [MyCustomAttribute(...)] [DataMember(IsRequired =
I have the following class: [DataContract] public class FileUploaderResult { [DataMember] public bool Success
I have the following class [DataContract(Namespace = , Name = VersionRange)] public sealed class
I have a following class : [DataContract] public class Pair<TKey, TValue> : INotifyPropertyChanged, IDisposable

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.