locked
Calling WCF Services from Custom Server Controls RRS feed

  • Question

  • User-732038307 posted

    Hi,

    I'm creating a main site along with some smaller associated sites and backend applications.  They all use the same WCF services.  I am creating multiple custom server controls to encapsulate common UI scenarios.  I need to have some of these controls call my WCF services (not necessarily through AJAX) but I'm unsure of the best way forward after experiencing some problems.

    If I create the same service ref in the controls project as is already in the 'host' project, I get clashes with types being duplicated.  This has lead me to think that maybe I should be defining an interface between the control and the application(s) so that the control can use the services as they are defined in the hosting project.  I'm not sure if this is possible, or recommended?  This would be sort of the same way that a class library project/DLL can see and access the .config file of the hosting application.

    Any advice on what the best model is in this scenario would be really appreciated.

    Thanks,
    Col

     

    Tuesday, November 27, 2007 5:00 AM

Answers

  • User-1136466523 posted

    Hi,

    as the whole idea is to have a re-usable controls project/dll.

    You may compile the custom control and load it into the GAC on your computer.

    Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, December 2, 2007 8:58 PM

All replies

  • User-1136466523 posted

    Hi,

    From your description, it seems that you want to call WCF service from your custom control, right?

    If I create the same service ref in the controls project as is already in the 'host' project

    There are several ways for you to create your custom control and add it into your project. In your case, since you need to add the service into your project for the custom control to consume , you should not create a webcontrollibrary project in your solution, instead, just write your custom control in your main project, add the service by “Add a service reference”, and then, write the consuming codes in your custom control. After all, compile it as a DLL file and put it in the bin folder of your application.

    For more information on WCF service, you may visit the WCF forum:
    http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=118&SiteID=1

    Thanks.

    Thursday, November 29, 2007 11:52 PM
  • User-732038307 posted

     thanks very much for replying.  I'm afraid your solution doesn't help though as the whole idea is to have a re-usable controls project/dll.

     Col
     

    Friday, November 30, 2007 6:24 AM
  • User-1136466523 posted

    Hi,

    as the whole idea is to have a re-usable controls project/dll.

    You may compile the custom control and load it into the GAC on your computer.

    Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, December 2, 2007 8:58 PM
  • User-1676314167 posted

    Placing custom server controls in the GAC is not really a good solution for multiple developer envoirnments.

    Thursday, October 29, 2009 12:11 PM