7

To design in such that it is easy to deploy dependencies with your app, and so that development environments are easy to set up, it is advantageous to isolate an app's dependencies from it's environment. That means the app can get its dependencies from a package manager, and it will not be affected by it's deployment environment (such as the GAC). This principle comes from the Dependencies section of the very interesting "Twelve-Factor App" standards.

In .Net, I guess this would mean explicitly specifying to use dependencies from the bin folder of an app? I am concerned that this might cause problems for shared, strongly-named assemblies. In this Microsoft article, Ferrandez says locking conflicts can occur if apps do not share strongly-named assemblies via the GAC, since the assembly is loaded into a shared domain.

The 12-factor app describes the pieces needed to satisfy this principle as a dependency declaration manifest and a dependency isolation tool.

Does anyone have an established setup for isolating dependencies which is working for you, and is safe for strongly-named assemblies? Are we in the .Net world stuck with separating all our apps into VM's to achieve isolation?


Personal context: I maintain a SAAS app where each server instance runs a few services/apps which engage in some inter-process communication. They have some strongly-named dependencies in common. Having the dependencies in the GAC makes deployment complex, setting up dev environments a pain, and restricts freedom to choose deployment environments. Even without the strong naming or shared dependency issue, I am interested to know how people do dependency declaration and/or isolation. Thanks!

6
  • 4
    I don't think you've provided enough detail in your question to make it sufficiently answerable. Why is the GAC out? What advantages? What do you mean by dependencies, and why is isolation (whatever that means) preferable? What are the 12 factors? Don't make us read an entire website to understand the context of your question. May 7, 2014 at 22:26
  • 2
    That Microsoft article you linked to was written in 2006 and applies specifically to ASP.NET 1.1 only. The problem doesn't exist in 2.0 or above. Are you strictly dependent on ASP.NET 1.1 still?
    – Eric King
    May 7, 2014 at 23:48
  • @EricKing may I what your source is for this problem no longer existing? I am still interested in how people are approaching dependency isolation in .Net and avoiding DLL Hell. Thanks. May 8, 2014 at 0:45
  • 1
    @Saber Did you read the comments of the article you posted? The author states, in response to a question: "In 2.0 the assemblies are not loaded domain neutral so you are right:) there was a very specific reason i mentioned 1.1."
    – Eric King
    May 8, 2014 at 14:53
  • Possibly related: Solving .dll Hell with the .Net framework. Unless I'm completely missing something here, .Net assemblies were designed to have application specific dependencies.
    – RubberDuck
    May 30, 2015 at 19:31

1 Answer 1

1

Using Nuget for library dependencies goes a long way toward dependency declaration and isolation.

The packages.config associated to each project can be read as a dependency declaration.

If those package references are marked 'private', they are bundled into the bin folder of your build outputs, and are presumably bundled for deployment. This avoids the requirement that all reference assemblies are GAC'd on the deployment box.

2
  • 2
    Sure, but is there some way to force the application to prefer the assembly in the bin folder, so that assemblies in the GAC are never selected instead? Thanks. Nov 2, 2014 at 9:20
  • I searched a bit around, and it seems that using gacutil to make sure that the GAC is empty is the only way to achieve this. As I don't want to empty the GAC on my machine, I just do this in a docker container. Jan 15, 2020 at 8:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.