Results 1 to 1 of 1

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

    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


Posting Permissions

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