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 7858319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:23:12+00:00 2026-06-02T21:23:12+00:00

I have a class that defines a transaction that needs to be shared between

  • 0

I have a class that defines a transaction that needs to be shared between two separate applications. They both have references to this library and can use the class as a data type, but cannot invoke any of its methods:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using ServerLibrary.MarketService;

namespace ServerLibrary
{
    [ServiceContract]
    public interface IService
    {
        [OperationContract]
        string GetData(int value);

        [OperationContract]
        CompositeType GetDataUsingDataContract(CompositeType composite);

        [OperationContract]
        bool ProcessTransaction(Transaction transaction);
    }

    [DataContract]
    public class CompositeType
    {
        bool boolValue = true;
        string stringValue = "Hello ";

        [DataMember]
        public bool BoolValue
        {
            get { return boolValue; }
            set { boolValue = value; }
        }

        [DataMember]
        public string StringValue
        {
            get { return stringValue; }
            set { stringValue = value; }
        }
    }

    // Transaction class to encapsulate products and checkout data
    [DataContract]
    public class Transaction
    {
        [DataMember]
        public int checkoutID;
        [DataMember]
        public DateTime time;
        [DataMember]
        public List<Product> products;
        [DataMember]
        public double totalPrice;
        [DataMember]
        public bool complete;

        public void Start(int ID)
        {
            checkoutID = ID;
            products = new List<Product>();
            complete = false;
        }

        public void Complete()
        {
            time = DateTime.Now;
            complete = true;
        }
    }
}

What am I doing wrong?

[UPDATE] I missed out the rest of the service.

Thanks.

  • 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-02T21:23:12+00:00Added an answer on June 2, 2026 at 9:23 pm

    In order to use the same .NET types from both the client and the server what you need to do is to add the data contract classes to a shared assembly that both the client and the host use. Then when your host is up and running and you do an add service reference there should be a checkbox that says reuse types from existing assembly.

    This will make WCF recreate your objects and with the methods and data that you are expecting.

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

Sidebar

Related Questions

I have an abstract class that defines some methods. This class has two subclasses.
I have a class that defines its own enum like this: public class Test
I have two different projects and in one, I have a class that defines
I have a class that defines the names of various session attributes, e.g. class
I have a class that defines a CallRate type. I need to add the
I have a Literal class that defines a text value and an ID. I
I have an actionscript file that defines a class that I would like to
I have an AbstractEntity class as superclass for all my entites that defines an
I have a python module that defines a number of classes: class A(object): def
I have the following setup: class.staff.php This defines many variables, the one I'm working

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.