Tech Off Thread

7 posts

A question for WCF gurus

Back to Forum: Tech Off
  • User profile image
    BitFlipper

    I'm not very familiar with WCF although a few years ago I did use it for IPC between two different processes on the same system. However in that case there was a DLL shared between the server/client which contained the interface.

    This is what I want to do now:

    Server:

    • Define an interface and add ServiceContract, OperationContract, etc attributes.

    Client:

    • Be able to consume the interface defined by the server without requiring a shared DLL or XML config file at runtime.

    Now the server and client are both projects within the same solution, and will never be compiled separately, but will run on different systems. So it is possible to share the same source files between the two projects (maybe that's all I need?). What I am looking for is to end up with both the server and client having a single *.exe file and not require a shared DLL or config file.

    Is this possible with WCF?

  • User profile image
    PopeDai

    I believe it is - but first: are you sure you need WCF?

  • User profile image
    itsnotabug

    You can instantiate endpoints, service models/security, etc.. purely in code at runtime... no need for external config files. I would host a sample service that looks like what you want, consume it in Visual Studio with the Add Service wizard, then inspect the WCF proxy classes that are generated for you. From that you should be able to reverse engineer how to do it all in code. I'm not sure if this would satisfy your no shared dll requirement though... because whatever model you come up with would probably be best in a class library (shared).

  • User profile image
    davewill

    ah. so you still want the benefits of the shared interface but don't want the separate dll for the interface.  seems like the proj file could be tweaked to do that.

        <Compile Include="..\SomeOtherDir\ICommon.vb" />

     

    EDIT: "tweaked" is a little vague.  add a new line similar to the above in the proj file that makes sense for the specific relative relationship between the projects.

  • User profile image
    myefforts2

    This is totally possible. Add the contract files to the client project as a link (Add | Existing Item | Add As Link). If you're willing to create the ChannelFactory on the client yourself then you don't need any config either.

  • User profile image
    davewill

    @myefforts2: Add As Link. Awesome. I've always wondered where that was in the IDE.

  • User profile image
    BitFlipper

    Thanks everyone for the suggestions.

    , myefforts2 wrote

    This is totally possible. Add the contract files to the client project as a link (Add | Existing Item | Add As Link). If you're willing to create the ChannelFactory on the client yourself then you don't need any config either.

    Yes I ended up adding the common files as a link to the other project. This works well and is the best way to share common files between different projects. I remember using links to files in a previous version of VS (maybe it was VS 2008), but it was very flaky at that time. Sometimes VS would get confused and even end up crashing. But it seems to work flawlessly in VS 2012.

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.