Last post Oct 29, 2009 12:11 PM by dwb
Nov 27, 2007 05:00 AM|ColMonty|LINK
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.
Nov 29, 2007 11:52 PM|Nai-Dong Jin - MSFT|LINK
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:
Nov 30, 2007 06:24 AM|ColMonty|LINK
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.
Dec 02, 2007 08:58 PM|Nai-Dong Jin - MSFT|LINK
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.
Oct 29, 2009 12:11 PM|dwb|LINK
Placing custom server controls in the GAC is not really a good solution for multiple developer envoirnments.