Tutorial :Can a windows service and a IIS site share the same dlls?



Question:

Can a windows service and a IIS site share the same dlls?

And maybe the configuration (web.config)?


Solution:1

Config file, definitely not.

DLLs, certainly you can write the DLL once and have both of them call into it - I'm assuming by IIS site you mean some sort of server side code like ASP.NET - but I usually copy the DLLs into the places that each of them expect to find their dependencies rather than messing around with PATH etc.


Solution:2

Yes, basically the share the dlls that are in GAC


Solution:3

What do you mean by share? They can certainly reference the same assemblies. If the assemblies are in the GAC it would be fine. Typically if you do not put stuff in the GAC, then the DLL's will live in the bin folders for each project. If you are not in the GAC, most often, your deployment or setup project will just lay down them in the appropriate places, even if there is more than one copy of the file. The duplication will not matter, especially since the code is the same.

You would not want to try to share the config files. The website would default to web.config and your service would default to [you service name].exe.config. Yes you could technically load the config dynamically for one or the other, but they will most likely be different. There will be all sorts of additional configuration for ASP.NET in the web.config that the service would not need.

If you did want to share some config info, I would reccommend keeping the 2 original configs, and have them reference a 3rd config that would have you common config settings. In each of the apps, you would look up this config location from their own config files, and dynamically load the 3rd one.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »