How to share modules between WCF webservices..

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 =)
Who is Participating?
DarrenSenior Software EngineerCommented:
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:

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,

DarrenSenior Software EngineerCommented:
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 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


DarrenSenior Software EngineerCommented:
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.


aamadoAuthor Commented:
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 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 =)
aamadoAuthor Commented:
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!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.