How to share modules between WCF webservices..

Posted on 2010-09-16
Medium Priority
Last Modified: 2012-06-22
Hi guys,

I've got a question that I thought I'd find the answer to pretty quickly, but that I'm now into my third day and can't find the answer..

We have created our first WCF webservice.  This will not be our only webservice.  We'd like to know what strategy (if any) can be used to share class modules across the webservices without having to recompile the webservices?    

On our ASP.NET site we can just copy a .cs file into the app_code directory and the website automatically uses the new code without having to publish the whole website.  Can we achieve a similar result with webservices? Basically, we'd like to create the interface and implementation in the webservice dll but only reference outside modules instead of including them in.  We'd like to be able to overwrite an existing module and have the webservice start using it without having to recompile and re-deploy the webservice.  

Is this possible?   I can't seem to find documentation on best practice for webservice design in this area.  Any help or link to a resource that discusses this would be very much appreciated.

Thanks in advance =)
Question by:aamado
  • 3
  • 2
LVL 18

Expert Comment

ID: 33699300
Hi Alan,

I'm just trying to get my head around your architecture and what you are trying to do.

This is supposed to represent a web page communicating with a WCF Web Service which communicates with outside DLL's / .cs files are you call them. An you want to be able to drop in newer versions of the outside DLL's/ cs files. The problem is that the webservice and the DLL's are compiledIs this correct?

                                                       /-> Outside DLL's modules
Web page <-> WCF/Web Services <-> Outside DLL'smodules
                                                       \-> Outside DLL'smodules

Or is it that you want to be able to actually rewrite the code.

                                                       /-> Outside modules .cs file
Web page <-> WCF/Web Services <-> Outside modules .cs file
                                                       \-> Outside modules .cs file

There are two things that I can think of, one is on this link http://msdn.microsoft.com/en-us/library/ms733766.aspx The other thing I can think of for the latter is the Code DOM. But I'm not 100% it would work for what you want exactly. It's something to look at though http://www.15seconds.com/issue/020917.htm


LVL 18

Expert Comment

ID: 33699315
Hi again,

Provided the interface doesn't change then you should be fine with whatever you do.

I think the first link I posted is the one you want although compiling it into a DLL will work either.



Author Comment

ID: 33705211
Hi Darren =)

Thanks for the reply,

The second example you stated is basically what we're trying to achieve.

Here's an image that would represent an example of the webservice file structure on our webserver.

Hopefully this will help explain better what i'm asking..

We would like to just be able to overwrite one of the classes (i.e. Myfunctions1.cs) and have the webservice start using it without having to recompile and publish out the webservice.

Right now what is happening is that when publishing out the webservice, the MyFunctions1.cs and Myfunctions2.cs files get compiled into the Service1.dll and that's what the Webservice references.

In our Asp.net websites we can just replace the .cs files in the App_Code directory and the website will just compile the .cs file on the fly and use it right away.

I'm not sure if that type of architecture is possible with webservices.  That's what we're trying to find out.

Thanks again,
-Alan =)
LVL 18

Accepted Solution

DarrenD earned 500 total points
ID: 33707596
Hi Alan,

I think that what you want is exactly what is in  the first link that I gave you as you do not have to compile into a DLL as this is done on the fly: http://msdn.microsoft.com/en-us/library/ms733766.aspx

I have tested this. Simply create a directory in IIS called IISServiceTest and add a sub directory call App_Code.

Then add the attached files to the following directories:


You should then be able to change the functions in Functions1.cs

This way you do not create a DLL. It is all done on the fly.

However the client will have to get the latest version of the Service Contract if new methods are added to it so that the client can see them. Services are different in that respect to normal ASP.NET

NB: Change CalcService.cs to CalcService.svc as EE would not let me upload it.

Let me know if this meets some of your requirements.

Hope this helps,



Author Comment

ID: 33708424
Hi Darren  :)

Yes that's perfect!  Just what we're looking for.  I didn't understand the link as well as I did the explanation in your last post,  thank you for that :)

Thanks again!

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial will show you how to add an attribute to an XML (http://en.wikipedia.org/wiki/XML) stream returned from a Windows Communication Foundation (http://en.wikipedia.org/wiki/Windows_Communication_Foundation) (WCF) Web Service.  Some knowled…
Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
Watch the video to learn how one can deal with PST file corruption issue with an outstanding Kernel for Outlook PST Repair Tool easily. Using this tool, non-technical users can swiftly perform the repair process to restore their essential data witho…
Suggested Courses
Course of the Month3 days, 23 hours left to enroll

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question