I've been struggling to do this in a way that fulfills all of my requirements.
Here is what we have in our library:
- Base classes for controllers and services
- Business objects (stores, departments, etc)
- Common Partial Views (Login, Error, etc)
- Base class for HttpApplication
- General common code (read an INI file, create a db conn, etc)
The one requirement that has been giving me trouble is as follows:
- Lives in one place on a server. (i.e. copy local = false)
This breaks because:
- The DLL containing the HttpApplication class must be in the same directory as the web apps dll to launch. I haven't found a way around that. I'm ok with duplicating this code in every app, but would rather not.
- The shared views don't like to work if I use Assembly.LoadFrom() to load the dll from the shared location. (I've been using this method to precompile my views)
- Any namespace shortcuts in web.config break at runtime with compilation errors because the web.config is parsed before the assembly is loaded.
My question to you folks is how do you handle your common code in a similar environment?
The GAC seems to be more trouble than its worth, and we want all of our apps to be using the same code, and not have multiple apps on multiple versions and have to maintain all of that. Are there design patters/best practices that can guide us in this regard?
Also, as a bonus, if you can solve any of the problems above, that would be great, too.
Thanks!
Edit: I guess a question that follows is whether or not we should even have a directory with the common dll(s) on the server, or if they should only be deployed as projects are deployed/updated?