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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:59:11+00:00 2026-06-15T11:59:11+00:00

I am a beginner to WCF. I am trying to make a device driver

  • 0

I am a beginner to WCF. I am trying to make a device driver network accessible.
Code I have right now, simplified:

A.cs

public class A {
    public int source;
}

Driver.cs

public class Driver {
    // some fields here
    A a;

    // singleton class
    private Driver() {
        a = null;
        // some more code
    }

    // static methods
    public static Driver OpenDevice(int n) {
        Driver d = null;
        // some code
        i = GetBoardNumber();
        // some native code to actually open driver ONLY IF it wasn't already opened!
        d = new Driver();
        return d;
    }
    public static int GetDeviceNumber() {
        // some native code get device number
        return someInt;
    }

    // some non static methods which use native code
    // example:
    public int ResetDevice(){
        // some code
        // call native i_ResetDevice() method
        return code;
    }
}

DllImport.cs

public class DllImport {
    // some code to import method definitions from dll
    // example:
    [DllImport("MyDeviceDriverProvidedForWindows.dll")]
        public static extern int i_ResetDevice();
    // some more code
}

This Driver works very well for me. In the examples that control the device, I simply add reference to this Driver and control the Device using driver’s methods.

MyService d = Driver.OpenDevice(0);
d.ControlDevice();

My job is to make this Driver remotely accessible, and I chose to do it using WCF.

Since, I already had implementation, I extracted an interface and turned it into a valid WCF service contract by putting OperationContracts and proper places. This extracted interface did not have the OpenDevice and GetDeviceNumber methods because, they were static.


The problems I am having are:

1) Opening WSDL file tells me to use some code like this in client:

MyServiceClient client = new MyServiceClient();
// access client operations
// close client
client.Close();

what is this MyServiceRefernce.MyServiceClient(MyServiceReference is name of the service reference I added to the client)? Why is it calling the private constructor of MyService class on server?

2) How can I do something like this in the client?

MyServiceReference.Driver d = MyServiceRefernce.Driver.OpenDevice(0);

I have read about InstanceContextMode but not really sure how to use it my situation.

I understand it is hard to understand what I am asking exactly, but it really is hard for me to explain too! I wish I had someone with me who knew WCF well.


The actual driver source I am using is in Assembly folder in this file.

  • 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-15T11:59:13+00:00Added an answer on June 15, 2026 at 11:59 am

    You not make a WCF service use a single instance by making the service class a singleton. You need to configure the WCF service so it uses only a single instance. Also you can create a session-based WCF service. See this, for example.

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

Sidebar

Related Questions

Beginner in Android development. My code crashes. I have made a simple Java method
I'm a beginner in WCF, which I have chosen instead of Web Services because
I'm trying to get WCF working with Silverlight. I'm a total beginner to WCF
Beginner Android and Java developer here. I have this snippet of code inside a
Beginner question. How come I can do this: Public Class Form1 Private StudentsInMyRoom As
Beginner with MATLAB here. I'm trying to write a class that will load in
Beginner iOS dev here. I have a problem in my array. Im making an
Beginner here trying to get a pipeline working in bash. If somebody can see
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
Beginner question: I have a dictionary where the values are lists of (a variable

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.