Results 1 to 4 of 4

Thread: WCF service library in self-hosted console server, and test client

  1. #1
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.5
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    15,083
    Reputation
    2803

    WCF service library in self-hosted console server, and test client

    This is basically an update of an old Remoting example I posted here 10 years ago, this example does the same with WCF.

    This VS 2015 solution contains three projects, configured as multi-startup:
    • WCF Service Library, includes the interface and implementation for one method, GetScreen, that takes screenshot of desktop and return it as a Stream.
    • Server, a Console application that is self-hosting the WCF library, all code is copied from a MSDN article (link in code).
    • Client, a Windows Forms application with a service reference to the WCF service. Calls the service method on button click.


    For debugging run VS as Administrator, this is necessary for service to register the base url. As alternative the solution can be compiled and set as single-startup project for Client. Then you run the server console manually from Windows Explorer with admin rights (right-click .exe, run as Admin), then run/debug just client. This is also useful if you want to change base url and need to update the service reference in Client project.

    Special considerations:
    • service method returns a Stream for image bytes rather than Image, because an Image object is not suitable for WCF message transmission.
    • the BasicHttpBinding in client app.config is modified for larger message size, because images takes more space than default message size.
    Attached Files Attached Files
    How to format posts with code blocks etc - present the problem/post properly

    Visual Studio Community 2017

  2. #2
    dwains is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.5
    Join Date
    Feb 2016
    Posts
    14
    Reputation
    16
    Hi John so I decided that WCF may be better it works great when both are on the localhost however I want to run the server from the server and the clients from various lan IP address's So I changed the server Line to http://192.168.254.1:8080/hello
    the console starts ok. But cant seem to figure out how to get the client to connect. The ultimate goal here is to have each client get a screen update from the server every second. Its looks as if I need to change the endpoint configuration according to the error message. I figured out that the endpoint was in the app.config file I pointed it to <endpoint address="http://192.168.254.1:8080/hello" binding="basicHttpBinding" but when I try to run more than one instance it cant because file is in use. Any thoughts on this?
    Thanks Dwain
    Last edited by dwains; 01-21-2017 at 10:20 AM.

  3. #3
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.5
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    15,083
    Reputation
    2803
    You can re-configure the client server reference within VS when you have server up, or you can manually change "client > binding" in clients app.config, this can also be done with the clients .config file manually after compile/deploy.
    How to format posts with code blocks etc - present the problem/post properly

    Visual Studio Community 2017

  4. #4
    dwains is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.5
    Join Date
    Feb 2016
    Posts
    14
    Reputation
    16
    Sorry having a senior moment lol. I was trying to run the same app twice of course the file was in use. The end result was editing the app config file as stated above.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •