views:

538

answers:

6

I haven't done a lot of .NET programming, but I have examined a few of the application blocks published by Microsoft's Patterns and Practices group. I was wondering how these are typically used:

  • Linked directly into applications
  • Source added into applications and built with them, perhaps with some customizations
  • Sample code used as reference while writing application-specific code

I'm sure all three of these usages are common, but what are the most typical usage patterns?

Are there a few particular application blocks that are used by "everyone?"

Note: This question is related to, but not the same as http://stackoverflow.com/questions/53065/enterprise-library-application-blocks-or-home-grown-framework.

+2  A: 

I usually put the source into my project, and then I can get better intellisense (and a better understanding of them). I don't tend to customize them at all though. I like to have them stock so I can just distribute the stock binaries anytime I need them.

Geoffrey Chetwood
+1  A: 

I've tried several Application Blocks of Entrerprise Lib 3.1 (May 2007) and here are somme comments :

Caching Application Block : Less interesting than System.Web.Caching in simple scenarios (like In-Memory caching) Exception Handling & Logging : Overcomplicated. NLog or Log4Net are better solutions.

I looked at the other Blocks but they didn't seem to fit for our projects.

Finally we completely dropped EntLib because it was painful to cutomize... I would advise you to really consider a less monolithic solution than EntLib.

Costo
+1  A: 

I think that most convenient way is to add App blocks\EntLib as a solution items. That way they will not be recompiled each time you build your project (they will not participate in build process at all) and you can easily access their source code\set breakpoint etc.

aku
FYI: You can add them in full and specify in configuration manager for them not to build with the solution.
Geoffrey Chetwood
I prefer to use solution items, it allows me to build solution even if entlib projects missing
aku
+2  A: 

We just put the EntLib 3.1 binaries in the global assembly cache and add references in our projects. We typically only use the logging framework, though.

tkrehbiel
+3  A: 

I have used Microsoft's Enterprise Library extensively. They generally should never be included within your project if possible. The added cost of compiling can be heavy. Additionally, there's no reason to have the source code in your project to use the classes. You will still get intellisence during coding as long as you add a reference to the DLL's in your projects. It is also advisable to avoid having mutliple codebases floating around your dev environment. If you need to customize the classes, open them up in their own solution and keep one version active. Of course I always strongly suggest using version control (VSS or Subversion) in case you need to roll back changes.

There are also open source alternatives to the Microsoft classes that are usually better coded (i.e. Log4Net, nUnit, etc.). Microsoft code tends to be bloated and inefficient.

Eric
A: 

We use the blocks by adding references to the DLLs, making sure that "copy local" is set so that they are deployed with the app into the app's bin folder. This means that we don't have to muck around with the GAC - much simpler!

When debugging, Visual Studio can still step into the source code even if it's not directly included in your project, as long as you have the EntLib source code on your hard disk somewhere. It will prompt you for the location on first use, and remember it thereafter.

We currently use the Caching, Exception and Logging blocks. We haven't thought of a use case for the rest yet.

Christian Hayter