none
Running WCF service and client in the same app domain RRS feed

  • Question

  • Hello,

    I have my WCF service hosted inside a Console application, creating the endpoints and behaviors programatically. 

    In the same solution, I have another Console application as a client which consumes this service. So far, its all good, working fine as expected.

    Now, I would like to run the client in the same appdomain as that of service and vice-versa.

    Any pointers to how can I do that?

    Thanks.

    Thursday, March 14, 2013 4:36 PM

Answers

  • Hi Deepak,

    If you want to run the WCF service and client in the same .NET app domain, why don't you encapsulate the WCF service into a service library (class library project). thus, you can directly move your WCF service hosting code into the client console app. That will surely make the service and client code execute in the same appdomain (since you just need to start a single console app). If you keep puting the service and client into two separate console app, so far I haven't found any means to load them in a single .NET app domain (although it is possible to load them into separate appdomains within the same process).


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 28, 2013 4:44 AM
    Moderator

All replies

  • If you want to run client as well as server in the same AppDomain, then why you need WCF, just create 2 classes and let them talk to each other using function calls.


    ViBi

    Thursday, March 21, 2013 9:54 AM
  • Thanks Eric.

    It seems first link has some different requirements to what I actually need. It was useful information though, thanks for sharing. About the second, I don't want to host the WCF in IIS. I need to use Visual studio development server to get the job done. 

    Saturday, March 23, 2013 3:21 PM
  • Hi ViBi,

    Let me elaborate on the what I actually need. 

    1. I have created a WCF service app which talks to the database for CRUD operations which takes place in a transaction scope.

    2. I have a console app which consumes this WCF service and talks to WCF within its own transaction scope.

    3. Now, with <transactionFlow = "true"> for wsHttpBindings, I need to demo whether transaction actually flows from client to service (same LocalId)

    4. Now, since they are in different app-domains, they have different LTM and hence different local ids. If the transaction does flow (transaction propagation of WCF), all must have the same same LocalIdentifier.  

    I hope I am now clear with what I actually want. Let me know if you need any more info.

    P.S.: This is just a simple POC I'm doing. I just don't want to make things work, I need to understand how they actually works!

    Saturday, March 23, 2013 3:31 PM
  • Hi Deepak,

    If you want to run the WCF service and client in the same .NET app domain, why don't you encapsulate the WCF service into a service library (class library project). thus, you can directly move your WCF service hosting code into the client console app. That will surely make the service and client code execute in the same appdomain (since you just need to start a single console app). If you keep puting the service and client into two separate console app, so far I haven't found any means to load them in a single .NET app domain (although it is possible to load them into separate appdomains within the same process).


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 28, 2013 4:44 AM
    Moderator